-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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" |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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.
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.
it may be think Proxy as a cache Directory for Doctrine.