Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training mahmoud #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Training mahmoud #4

wants to merge 5 commits into from

Conversation

mahmoud-hussien1
Copy link
Collaborator

@mahmoud-hussien1 mahmoud-hussien1 commented Jul 5, 2018

Note:

it's good to run deploy.sh file to let Doctrine get access to it's Proxy Directory (data/DoctrineORMModule/Proxy) after createing this Directory if not exist.

  • After search, i get that Doctrine have not access to Proxy By default. so, when Doctrine use it, exception happens.
    it may be think Proxy as a cache Directory for Doctrine.

Copy link
Member

@zhibek zhibek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good overall, but I'm pointing out some areas that should change.

@@ -23,4 +23,4 @@ services:
volumes:
- .db:/var/lib/mysql
ports:
- "3306:3306"
- "3307:3306"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than committing this change, you can stop your local mysql service running while you're using Docker for this project.

'doctrine' => [
'configuration' => [
'orm_default' => [
'proxy_dir' => __DIR__.'/../../data/DoctrineORMModule/Proxy',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not mandatory to set this (system temporary directories are used by default, which have the correct permissions) and in our Docker environment we want to keep things simple.


return [
'view_manager' => [
'display_exceptions' => true,
],
'service_manager' => [
'factories' => [
'stdClass' => InvokableFactory::class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an example? I'm not seeing this used anywhere in your code.

],
],
'view_manager' => [
'display_not_found_reason' => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to duplicate keys here that we already have declared in the Application module. The keys from config of each module get merged together (they're not kept separately for each module). This applies to most of the keys in this view_manager config - you should remove them all, apart from the ones which are specific to the Category module, such as the 3 template_map files and the template_path_stack (which is specific to the Category module as it uses DIR to refer to the Category module directory).

'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../../../view/layout/layout.phtml',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All templates should be in view directories inside a module directory.

The layout.phtml template (and other site-wide templates, like error templates) should be in the Application module, while module-specific templates should be in the view directory of that module.

* Time: 10:45 AM
*/

namespace Product\model;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always use TitleCase for namespaces / classnames (Product\Model not Product\model).

*/
private $entityManager;

public function __construct($serviceManager)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than injecting the $serviceManager, you should inject directly the services you need - in this case $entityManager, although really you should inject own service (CategoryModel) in this module and inject that (with $entityManager injected into that service, instead of into this controller).

Injecting the $serviceManager is considered to be an anti-pattern.

{


// $entityManager = $container->get('doctrine.entitymanager.orm_default');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (commented) line shows the right idea. We should inject specific services (e.g. the ORM) rather than the $serviceManager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants