Exemplo n.º 1
0
 protected function xmlEncode()
 {
     $this->writer = new XmlWriter();
     $this->writer->openMemory();
     $this->writer->startDocument('1.0', 'UTF-8');
     $this->writer->startElement(\strtolower(denamespace($this->model)));
     $this->write($this->toArray());
     $this->writer->endElement();
     $this->writer->endDocument();
     $xml = $this->writer->outputMemory(true);
     if (@$this->options['skip_instruct'] == true) {
         $xml = \preg_replace('/<\\?xml version.*?\\?>/', '', $xml);
     }
     return $xml;
 }
Exemplo n.º 2
0
 /**
  * Constructs a relationship.
  *
  * @param array $options Options for the relationship (see {@link valid_association_options})
  * @return mixed
  */
 public function __construct($options = array())
 {
     $this->attribute_name = $options[0];
     $this->options = $this->merge_association_options($options);
     $relationship = strtolower(denamespace(get_called_class()));
     if ($relationship === 'hasmany' || $relationship === 'hasandbelongstomany') {
         $this->poly_relationship = true;
     }
     if (isset($this->options['conditions']) && !is_array($this->options['conditions'])) {
         $this->options['conditions'] = array($this->options['conditions']);
     }
     if (isset($this->options['class'])) {
         $this->class_name = $this->options['class'];
     } elseif (isset($this->options['class_name'])) {
         $this->class_name = $this->options['class_name'];
     }
     $this->attribute_name = strtolower(Inflector::instance()->variablize($this->attribute_name));
     if (!$this->foreign_key && isset($this->options['foreign_key'])) {
         $this->foreign_key = is_array($this->options['foreign_key']) ? $this->options['foreign_key'] : array($this->options['foreign_key']);
     }
 }
Exemplo n.º 3
0
 public function keyify($class_name)
 {
     return strtolower($this->underscorify(denamespace($class_name))) . '_id';
 }
Exemplo n.º 4
0
 protected function keyify($class_name)
 {
     return strtolower(classify(denamespace($class_name))) . '_id';
 }