1 | <?php |
||
25 | trait DomainModelAwareTrait |
||
26 | { |
||
27 | /** |
||
28 | * Service Locator Registry |
||
29 | * |
||
30 | * @var \Cake\Core\ObjectRegistry |
||
31 | */ |
||
32 | protected $domainModelLocator; |
||
33 | |||
34 | /** |
||
35 | * Default Domain Model Locator Class |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $defaultDomainModelLocator = DomainModelLocator::class; |
||
40 | |||
41 | /** |
||
42 | * Load a Domain Model |
||
43 | * |
||
44 | * @param string $model Domain Model Name |
||
45 | * @param array $constructorArgs Constructor Args |
||
46 | * @param bool $assignProperty Assigns the domain model to a class property of the same name |
||
47 | * @return \stdClass |
||
48 | */ |
||
49 | public function loadService($model, array $constructorArgs = [], $assignProperty = false) |
||
67 | |||
68 | /** |
||
69 | * Get the service locator |
||
70 | * |
||
71 | * @return \Cake\Core\ObjectRegistry |
||
72 | */ |
||
73 | public function getDomainModelLocator() |
||
82 | |||
83 | /** |
||
84 | * Sets the Domain model locator |
||
85 | * |
||
86 | * @param \Cake\Core\ObjectRegistry $locator Locator |
||
87 | * @return void |
||
88 | */ |
||
89 | public function setDomainModelLocator(ObjectRegistry $locator) |
||
93 | } |
||
94 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: