public function addEventArgumentBuilder($id, array &$attributes) { if (!isset($attributes['alias'])) { throw new \Exception(sprintf("service(%s, tags:{name:%s}) require alias", $id, self::_TAG_NAME)); } $name = $attributes['alias']; if (!PhpHelper::isPropertyName($name) || in_array($name, $this->_ignore_properties_list)) { throw new \Exception(sprintf("service(%s, tags:{name:%s, alias:%s}) tag.alias invalid", $id, self::_TAG_NAME, $name)); } if (!isset($attributes['parent'])) { throw new \Exception(sprintf("service(%s, tags:{name:%s, alias:%s}) require parent", $id, self::_TAG_NAME, $name)); } $parent_name = $attributes['parent']; if (!$this->hasEventBuilder($parent_name)) { throw new \Exception(sprintf("service(%s, tags:{name:%s, alias:%s, parent:%s}) tag.parent must be one of(%s)", $id, self::_TAG_NAME, $name, $parent_name, join(',', array_keys($this->_events)))); } $parent = $this->getEventBuilderByName($parent_name); if ($parent->hasEventArgumentBuilder($name)) { throw new \Exception(sprintf("service(%s, tags:{name:%s, alias:%s, parent:%s}) conflict with service(%s)", $id, self::_TAG_NAME, $name, $parent_name, $parent->getEventArgumentBuilderByName($name)->getId())); } $builder = new SymforceEventArgsBuilder(); $builder->setId($id); $builder->setName($name); if (!isset($attributes['type'])) { throw new \Exception(sprintf("service(%s) with tags(name=%s, alias=%s, parent=%s) require type", $id, self::_TAG_NAME, $name, $parent_name)); } $builder->setType($attributes['type']); if (isset($attributes['value'])) { $builder->setDefaultValue($attributes['value']); } $parent->addEventArgumentBuilder($builder); }
public function addAnnotationPropertyCompiler($id, array &$attributes) { if (!isset($attributes['alias'])) { throw new \Exception(sprintf("service(%s, tags:{name: %s}) require tag alias", $id, self::PROPERTY_TAG_NAME)); } $name = $attributes['alias']; if (!PhpHelper::isPropertyName($name) || in_array($name, $this->_ignore_name_list)) { throw new \Exception(sprintf("service(%s, tags:{name: %s, alias: %s}) tag alias invalid", $id, self::PROPERTY_TAG_NAME, $name)); } $builder = new SymforceAnnotationPropertyBuilder(); $builder->setId($id); $builder->setName($name); if (isset($attributes['parent'])) { $parent_name = $attributes['parent']; if (!isset($this->class_builders[$parent_name])) { throw new \Exception(sprintf("service(%s, tags:{name: %s, alias: %s, parent: %s}) parent must be one of (%s)", $id, self::PROPERTY_TAG_NAME, $name, $parent_name, join(',', array_keys($this->class_builders)))); } $parent = $this->getClassBuilderByName($parent_name); if ($parent->hasPropertyBuilder($name)) { throw new \Exception(sprintf("service(%s, tags:{name: %s, alias: %s, parent: %s}) parent must be one of (%s)", $id, self::PROPERTY_TAG_NAME, $name, $parent_name, $parent->getPropertyBuilder($name)->getId())); } $parent->addPropertyBuilder($builder); } else { if (isset($this->public_properties[$name])) { throw new \Exception(sprintf("service(%s, tags:{name: %s, alias: %s}) conflict with service(%s) tag alias", $id, self::PROPERTY_TAG_NAME, $name, $this->getPropertyBuilderByName($name)->getId())); } $this->public_properties[$name] = $builder; } if (isset($attributes['type'])) { if (!in_array($attributes['type'], $this->_default_property_types)) { throw new \Exception(sprintf("service(%s, tags:{name: %s, alias: %s, type: %s}) type must be one of(%s)", $id, self::PROPERTY_TAG_NAME, $name, $attributes['type'], join(',', $this->_default_property_types))); } $builder->setType($attributes['type']); } }