コード例 #1
0
 protected function initServices()
 {
     $servicesConfig = $this->config->getSection('services');
     $servicesConfig = $servicesConfig ? $servicesConfig : [];
     $this->components = [];
     foreach ($servicesConfig as $componentId => $componentConfig) {
         $this->validateConfigComponentClass($componentConfig);
         $component = null;
         $componentClass = $componentConfig['class'];
         unset($componentConfig['class']);
         if (isset($componentConfig['params'])) {
             $component = new $componentClass($componentConfig['params']);
             unset($componentConfig['params']);
         } else {
             $component = new $componentClass();
         }
         foreach ($componentConfig as $name => $value) {
             if (property_exists($component, $name)) {
                 $component->{$name} = $value;
             } else {
                 if (method_exists($component, 'set' . ucfirst($name))) {
                     $component->{'set' . ucfirst($name)}($value);
                 } else {
                     throw new SystemException('Class "' . $componentClass . '" has no property "' . $name . '" or method "' . 'set' . ucfirst($name) . '"');
                 }
             }
         }
         $this->components[$componentId] = $component;
     }
     Model::init($this->getComponent('db'));
     View::setTemplateDirectory($this->config->getParameter('templatePath'));
 }
コード例 #2
0
 public function save()
 {
     if (!$this->createdAt) {
         $this->createdAt = new \DateTime();
     }
     parent::save();
 }
コード例 #3
0
ファイル: Post.php プロジェクト: pavelkolomitkin/nigma-blog
 public function save()
 {
     $this->updatedAt = new \DateTime();
     parent::save();
 }