Nette\PhpGenerator\ClassType::addConst PHP Метод

addConst() публичный Метод

public addConst ( $name, $value ) : self
Результат self
    public function addConst($name, $value)
    {
        $this->consts[$name] = $value;
        return $this;
    }

Usage Example

Пример #1
0
 public function onGenerate(AbstractMetaSpec $spec, MetaSpecMatcher $matcher, Type $type, ClassType $class)
 {
     $class->addConst("CLASS_NAME", $type->getName());
     $class->addConst("SHORT_NAME", $type->getShortName());
     $class->addConst("ENTITY_NAME", lcfirst($type->getShortName()));
     foreach ($type->getProperties() as $property) {
         $const = strtoupper(trim(preg_replace("/([A-Z])/", "_\$1", $property->getName()), "_"));
         if (isset(self::$reserved[$const])) {
             throw new MetaException("Property name constant for {$type->getName()}::\${$property->getName()} would result in reserved word.");
         }
         $class->addConst($const, $property->getName());
     }
 }
All Usage Examples Of Nette\PhpGenerator\ClassType::addConst