예제 #1
0
파일: User.php 프로젝트: marvin255/bxar
 /**
  * Возвращает атрибут модели по указанному имени
  * @param string $name
  * @return null|\bxar\IAttribute
  */
 public function getAttribute($name)
 {
     $name = $this->prepareAttributeName($name);
     //грузим каждый атрибут только при первом обращении к нему
     if (array_key_exists($name, $this->_initOnDemand)) {
         $init = array('model' => $this, 'code' => $name, 'value' => $this->_initOnDemand[$name]);
         $desc = $this->getUserFieldsDescription();
         foreach ($desc as $field) {
             $fName = $this->prepareAttributeName($field['FIELD_NAME']);
             if ($fName === $name) {
                 $init['params'] = $field;
                 break;
             }
         }
         $obj = $this->createAttributeFromSettings($init);
         $this->setAttribute($name, $obj);
         unset($this->_initOnDemand[$name]);
     }
     return parent::getAttribute($name);
 }
예제 #2
0
파일: Section.php 프로젝트: marvin255/bxar
 /**
  * Возвращает атрибут модели по указанному имени
  * @param string $name
  * @return null|\bxar\IAttribute
  */
 public function getAttribute($name)
 {
     $name = $this->prepareAttributeName($name);
     //грузим каждый атрибут только при первом обращении к нему
     if (array_key_exists($name, $this->_initOnDemand)) {
         $init = array('model' => $this, 'code' => $name, 'value' => $this->_initOnDemand[$name]);
         $obj = $this->createAttributeFromSettings($init);
         $this->setAttribute($name, $obj);
         unset($this->_initOnDemand[$name]);
     }
     return parent::getAttribute($name);
 }
예제 #3
0
파일: Element.php 프로젝트: marvin255/bxar
 /**
  * Возвращает атрибут модели по указанному имени
  * @param string $name
  * @return null|\bxar\IAttribute
  */
 public function getAttribute($name)
 {
     $name = $this->prepareAttributeName($name);
     //грузим каждый атрибут только при первом обращении к нему
     if (array_key_exists($name, $this->_initOnDemand)) {
         $init = array('model' => $this, 'code' => $name, 'value' => $this->_initOnDemand[$name]);
         if (strpos($name, 'property_') === 0) {
             $code = str_replace('property_', '', $name);
             $iblockId = isset($this->_initOnDemand['iblock_id']) ? $this->_initOnDemand['iblock_id'] : $this->getAttribute('iblock_id')->getValue();
             $iblock = $this->getIblockDescription($iblockId);
             foreach ($iblock['PROPERTIES'] as $property) {
                 if ($property['ID'] === $code || $property['CODE'] === $code) {
                     $init['params'] = $property;
                     break;
                 }
             }
         }
         $obj = $this->createAttributeFromSettings($init);
         $this->setAttribute($name, $obj);
         unset($this->_initOnDemand[$name]);
     }
     return parent::getAttribute($name);
 }