Pimcore\Model\Property\Predefined::getByKey PHP Метод

getByKey() публичный статический Метод

public static getByKey ( string $key ) : self
$key string
Результат self
    public static function getByKey($key)
    {
        $cacheKey = "property_predefined_" . $key;
        try {
            $property = \Zend_Registry::get($cacheKey);
            if (!$property) {
                throw new \Exception("Predefined property in registry is null");
            }
        } catch (\Exception $e) {
            try {
                $property = new self();
                $property->setKey($key);
                $property->getDao()->getByKey();
                \Zend_Registry::set($cacheKey, $property);
            } catch (\Exception $e) {
                return null;
            }
        }
        return $property;
    }

Usage Example

 public function installProperties()
 {
     $defProperty = Property\Predefined::getByKey('assigned_language');
     if (!$defProperty instanceof Property\Predefined) {
         $languages = \Pimcore\Tool::getValidLanguages();
         $data = 'all,';
         foreach ($languages as $language) {
             $data .= $language . ',';
         }
         $data = rtrim($data, ',');
         $property = new Property\Predefined();
         $property->setType('select');
         $property->setName('Assigned Language');
         $property->setKey('assigned_language');
         $property->setDescription('set a specific language which lucene search should respect while crawling.');
         $property->setCtype('asset');
         $property->setData('all');
         $property->setConfig($data);
         $property->setInheritable(FALSE);
         $property->save();
     }
 }
All Usage Examples Of Pimcore\Model\Property\Predefined::getByKey