Project Page:
http://drupal.org/sandbox/bmoresafety20/1879546

Repository:
git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/bmoresafety20/1879546.git se

Core:
7.x

Description:
The SE (Simple Entities) module is aimed at developers writing custom Entity implementations. It provides a couple of classes that assist with basic CRUD functionality for Entities within Drupal. I've been working with various implementations of Entities for some time now and I've yet to see an easy to use method to use Entities in custom code.

Packaged with this module is a sub module called se_example. The se-example module demonstrates the bare minimums required to get custom Entities working with the SE module. This includes basic CRUD functionality along with interfacing the Entity with form submissions. Detailed instructions in README.txt to follow shortly.

The Coder module found one potential issue where it recommended using check_plain() to sanitize user input, this is already in place. The SE module has also passed the PAReview.sh with no issues http://ventral.org/pareview/httpgitdrupalorgsandboxbmoresafety201879546git-7x-1x. As always another set of eyes is welcome to look over the code for potential security issues or other necessary changes.

Thanks, hope you like it.

Comments

ahlofan’s picture

Hi kerasai,

I don't see any commits. Also, I think you should have more detail about this module on your project page.

kerasai’s picture

Hello. You need to checkout the 7.x-1.x branch. I was able to pull the repo using the clone command in the initial post.

I'll be adding more details on the project page and the README files.

jooplaan’s picture

Status: Needs review » Needs work

Interesting project. As a developer this looks like a very handy tool to have around.

run the automated test on http://ventral.org/pareview/httpgitdrupalorgsandboxbmoresafety201879546git
no errors or warnings found

Installed the example module and run the coder module check. One thing came up for the example module:

se_example.module

Line 187: Potential problem: confirm_form() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
return confirm_form($form, $question, $path);

When trying to use the form created by the example module, to add a new entity there was a PDO exception when trying to add a second item:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'uid': INSERT INTO {se_example} (uid, created, modified, text) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => 1357280668 [:db_insert_placeholder_2] => 1357280668 [:db_insert_placeholder_3] => test 3 ) in drupal_write_record() (line 7106 of /opt/drupal/notificare/drupal-7.18/includes/common.inc).

You may want to add some more instructions and/or examples in the README, on practical use.

kerasai’s picture

Hello jooplaan. During development I changed my mind on what I wanted the se_example module to do, so the schema was limiting to one record per user. I've adjusted the schema to not enforce unique uids as it is now intended to work. Please completely uninstall the module, then reinstall to rebuild the tables with the appropriate schema.

Documentation and details on the way.

ahlofan’s picture

Right, sorry didn't know that. The idea of this module is really useful indeed. I tried your module, as mention in jooplaan's review, there is an error when added a second record.

I think there can be a lot more room to improve this module. I know this is just example module, for I guess you can add more the demo nicer code.
I see there a quit a few of code need to hardcode the path, i.e.
function se_example_form_delete(&$form, &$form_state) {
$form_state['redirect'] = "se-example/{$form_state['storage']['se']->sid}/delete";
}

I think it would be nice to have a piece of code to get the path maybe? or a const? i.e.
function se_example_get_path() {
// Directly from the schema
$schema = se_example_schema();
return str_replace('_', '-', array_shift(array_keys($schema)));
// Or simply return a path
return 'se-example';
}

I think it would be nice to add a pager to the listing page as well.

Cheers!

kerasai’s picture

Status: Needs work » Needs review

The schema is straightened-out as indicated in #4, so the se_example module is working as expected.

I've added more info to the project page and drafted a README for the se module, still pending on the README for the se_example submodule.

As far as improvements go:

Paths in se_example - I don't see the upside to making this dynamic. Everything happens all under that same path, 'se-example'. A constant is a good idea, but I think it's cleaner with the single string rather than a few strings concatenated together. I'm open to input, though.

Views integration - It's probably more worthwile to expose the table to Views and use a View to render the table rather than messing with a pager or trying to deal with click sorting, etc. I may get around to that.

robinvdvleuten’s picture

I've also worked with entities a lot and always used the Entity API module as base for my entity crud implementations. In which functionality differentiates your module from the Entity API module? After a manual review of your code, it is a very limited version of it and can't see any usecases yet for your module where the Entity API lacks functionality.
Maybe you can clarify this a bit more in the description of your module what the difference is and when to use your module instead of the Entity API.

iwhitcomb’s picture

Status: Needs review » Needs work

I tend to agree with robinvdvleuten. While I do see the value in having this in your toolkit, I don't know that a Drupal module is really appropriate here being that Entity API module already does much of what you're offering here.

See Entity API and ECK modules.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. Feel free to reopen if you are still working on this application.

I'm a robot and this is an automated message from Project Applications Scraper.

PA robot’s picture

Issue summary: View changes

Adjusted the repository URL to use HTTPS and that it would not require authentications.