public function getMethodSrc()
 {
     $template = static::$template;
     $template = str_replace('<visibility>', self::$visibility, $template);
     $template = str_replace('<space>', self::$space, $template);
     $template = str_replace('<eol>', self::$eol, $template);
     $template = str_replace('<column|capitalize>', Utils::capitalize($this->property), $template);
     $template = str_replace('<column>', $this->property, $template);
     return $template;
 }
Ejemplo n.º 2
0
 protected function buildMethod($template, $visibility, $property)
 {
     $template = str_replace('<visibility>', $visibility, $template);
     $template = str_replace('<space>', self::$space, $template);
     $template = str_replace('<eol>', self::$eol, $template);
     $template = str_replace('<column|capitalize>', Utils::capitalize($property), $template);
     $template = str_replace('<column>', $property, $template);
     return $template;
 }
Ejemplo n.º 3
0
 /**
  * Inverse the hydrate method
  * @param $entity
  * @return array
  */
 public function getData($entity)
 {
     $column = $this->analyzer->listColumns();
     $data = array();
     foreach ($column as $key => $value) {
         $method = 'get' . Utils::capitalize($key);
         $data[$key] = $entity->{$method}();
         if (is_null($data[$key])) {
             $data[$key] = array();
         }
         if ($data[$key] instanceof ArrayCollection) {
             $data[$key] = $data[$key]->toArray();
         }
     }
     return $data;
 }
Ejemplo n.º 4
0
 /**
  * Get the list of require method
  * @return array
  */
 public function listRequiredMethod()
 {
     if (!is_null($this->listRequiredMethod)) {
         return $this->listRequiredMethod;
     }
     $columns = $this->listColumns();
     $methodList = array();
     foreach ($columns as $name => $schema) {
         $methodList['get' . Utils::capitalize($name)] = array('type' => self::GETTER, 'column' => $name);
         switch ($schema['type']) {
             case 'array':
                 $methodList['add' . Utils::Capitalize($name)] = array('type' => self::ADDER, 'column' => $name);
                 $methodList['remove' . Utils::Capitalize($name)] = array('type' => self::REMOVER, 'column' => $name);
                 break;
             case 'string':
                 $methodList['set' . Utils::Capitalize($name)] = array('type' => self::SETTER, 'column' => $name);
                 break;
             case 'entity':
                 $methodList['add' . Utils::Capitalize($name)] = array('type' => self::ADDER, 'column' => $name);
                 $methodList['remove' . Utils::Capitalize($name)] = array('type' => self::REMOVER, 'column' => $name);
                 break;
         }
     }
     $this->listRequiredMethod = $methodList;
     return $methodList;
 }
 protected function methodSetter(array &$methodList, $name)
 {
     $methodList['set' . Utils::Capitalize($name)] = array('type' => self::SETTER, 'column' => $name);
 }