public function throwError() { $msg = call_user_func_array('sprintf', func_get_args()); $_msg = sprintf("%s, from annotation: `%s`, class: `%s` file: `%s` ", $msg, $this->getMeteTypeName(), $this->admin_object->class_name, $this->admin_object->getFileName()); if ($this->_chain_exception) { throw new \Exception($_msg, __LINE__, $this->_chain_exception); } else { throw new \Exception($_msg); } }
public function __construct(Entity $admin, $property, Annotation\Owner $annot) { $map = $admin->getPropertyDoctrineAssociationMapping($property); if (!$map) { $this->throwError("property:%s should set @Doctrine\\ORM\\Mapping\\OneToOne(targetEntity=%s)", $property, self::PAGE_ENTITY_CLASS); } if (self::USER_ENTITY_CLASS !== $map['targetEntity']) { $this->throwError("property:%s should set @Doctrine\\ORM\\Mapping\\ManyToOne(targetEntity=%s), you set to:%s", $property, self::USER_ENTITY_CLASS, $map['targetEntity']); } $this->setAdminObject($admin); $this->owner_property = $property; $this->setMyPropertie($annot); }
public function __construct(Entity $admin, $property, Annotation\Page $annot) { if ($admin->class_name === self::PAGE_ENTITY_CLASS) { $this->throwError("can not set Page for entity:%s", self::PAGE_ENTITY_CLASS, $property); } $map = $admin->getPropertyDoctrineAssociationMapping($property); if (!$map) { if ($admin->orm_metadata->hasField($property)) { $orm_type = $admin->orm_metadata->orm_metadata->getTypeOfField($property); $this->throwError("property:%s can not use orm type(%s)", $property, $orm_type); } else { /** * single page without OneToOne map , need set a parent id for this collection */ } } else { if (self::PAGE_ENTITY_CLASS === $map['targetEntity']) { /** * single page with OneToOne map, need set a parent id for this collection */ if (\Doctrine\ORM\Mapping\ClassMetadataInfo::ONE_TO_ONE !== $map['type']) { $this->throwError("property:%s map to %s must be One2One, you use %s", $property, self::PAGE_ENTITY_CLASS, $map['type']); } if (self::PAGE_ENTITY_CLASS === $admin->class_name) { $this->throwError("property:%s can not use Page(%s) to it self", $property, self::PAGE_ENTITY_CLASS); } $this->page_one2one_map = true; } else { $this->parent_entity = $map['targetEntity']; } } $this->page_property = $property; $this->setAdminObject($admin); $this->setMyPropertie($annot); if (!$this->title_property) { if ($admin->property_value_name) { $this->title_property = $admin->property_value_name; } else { // $this->throwError("page must set a title property"); } } if (!$this->controller) { $controller = preg_replace('/\\\\Entity\\\\(\\w+)$/', '\\\\Controller\\\\\\1Controller', $admin->class_name); if (class_exists($controller)) { $this->set_controller($controller); } } $this->_compile_class_name = $admin->_compile_class_name . 'WebPageGenerator'; }
public function __construct(Entity $admin, $property, Annotation\Column $annot) { $map = $admin->getPropertyDoctrineAssociationMapping($property); if (!$map) { $this->throwError("property:%s should set @Doctrine\\ORM\\Mapping\\OneToOne(targetEntity=%s)", $property, self::PAGE_ENTITY_CLASS); } else { if (self::PAGE_ENTITY_CLASS !== $map['targetEntity']) { $this->throwError("property:%s should set @Doctrine\\ORM\\Mapping\\OneToOne(targetEntity=%s), you set to:%s", $property, self::PAGE_ENTITY_CLASS, $map['targetEntity']); } } $this->setAdminObject($admin); $this->column_property = $property; $this->setMyPropertie($annot); if (!$this->title_property) { if (!$admin->property_value_name) { $this->throwError("page must set a title property"); } $this->title_property = $admin->property_value_name; } }
public function compile() { $class = $this->admin->getCompileClass(); if ($this->route_root) { $class->addProperty('_admin_route_root', $this->route_root); } if (!empty($this->_route_children)) { $class->addProperty('_admin_route_children', $this->_route_children); /* \Dev::debug($this->admin->name, 'children'); \Dev::dump( $this->_route_children); */ } if (!empty($this->_route_parents)) { $parents = array(); foreach ($this->admin->generator->admin_deep_order as $parent_name) { if (!isset($this->_route_parents[$parent_name])) { continue; } $o = $this->_route_parents[$parent_name]; if (count($o) > 1) { foreach ($o as $c) { $child_property = $c[0]; $parent_property = $c[1]; // if( !$parent_property ) continue ; if (!isset($parents[$parent_name])) { $parents[$parent_name] = array(1, array()); } $parents[$parent_name][1] = array($parent_property, $child_property); } } else { foreach ($o as $c) { $child_property = $c[0]; $parent_property = $c[1]; // if( !$parent_property ) continue ; $parents[$parent_name] = array(0, array($parent_property, $child_property)); } } } /* \Dev::debug($this->admin->name, 'parents'); \Dev::dump($parents, 8); */ $class->addProperty('_admin_route_parents', $parents); } }
/** * * @return array */ public function getPropertyDoctrineAssociationMapping() { return $this->admin_object->getPropertyDoctrineAssociationMapping($this->class_property); }