Exemple #1
0
 /**
  * @param array $options
  * @return void
  */
 public function setOptions($options = array())
 {
     if ($options instanceof \Zend_Config) {
         $options = $options->toArray();
     }
     StaticConfigurator::SetOptions($this, $options);
 }
Exemple #2
0
 /**
  *
  * @param array $options
  */
 public function __construct($options = array())
 {
     StaticConfigurator::setOptions($this, $options);
     if (!isset($options['charset'])) {
         $options['charset'] = 'utf-8';
     }
     parent::__construct($options['charset']);
 }
Exemple #3
0
 /**
  *
  * @param array $options
  * @throws \InvalidArgumentException
  * @return \NetCore\Platnoscipl\Button
  */
 public function setOptions(array $options = array())
 {
     if (!is_array($options)) {
         throw new \InvalidArgumentException('Wrong data type given. Expected array or Zend_Config object', 500);
     }
     \NetCore\Configurable\StaticConfigurator::setOptions($this, $options);
     return $this;
 }
Exemple #4
0
 public static function renderObjectProperty($object, $property)
 {
     if (is_array($object)) {
         return isset($object[$property]) ? $object[$property] : '';
     } else {
         if (is_object($object) && isset($object->{$property})) {
             return isset($object->{$property}) ? $object->{$property} : '';
         }
     }
     $getterCamelCased = 'get' . StaticConfigurator::toPascalCased($property);
     if (method_exists($object, $getterCamelCased)) {
         return $object->{$getterCamelCased}();
     }
     $getter_underscored = 'get_' . StaticConfigurator::toUnderscored($property);
     if (method_exists($object, $getter_underscored)) {
         return $object->{$getter_underscored}();
     }
     return '';
 }
Exemple #5
0
 public function fromArray($array)
 {
     $this->data = array_merge($this->data, $array);
     \NetCore\Configurable\StaticConfigurator::setOptions($this, $array);
     return $this;
 }
 /**
  * @param array $options
  * @return ConfigurableEventDispatcher
  */
 public function setOptions($options = array())
 {
     $this->options = array_merge($this->options, $options);
     StaticConfigurator::setOptions($this, $options);
     return $this;
 }
Exemple #7
0
 /**
  * @param array
  * @return \NetCore\Platnoscipl\Helper
  */
 public function __construct($options = array())
 {
     \NetCore\Configurable\StaticConfigurator::setOptions($this, $options);
     return $this;
 }
Exemple #8
0
 /**
  * @param array $options
  * @return \NetCore\Sode\Document\Element
  */
 public function setOptions($options = array())
 {
     StaticConfigurator::SetOptions($this, $options);
     return $this;
 }
Exemple #9
0
 /**
  * @param array $options
  * @return void
  */
 public function fromArray(array $options = array())
 {
     StaticConfigurator::SetOptions($this, $options);
 }
Exemple #10
0
 /**
  * @param array $arr
  * @return void
  */
 public function fromArray($arr = array())
 {
     StaticConfigurator::SetOptions($this, $arr);
 }
Exemple #11
0
 /**
  *
  * This function sorts all data by default $sortBy = 'id', and default sorting
  * direction $direction = 'asc' (ascending).
  * Returns sorted array of $data.
  *
  * @param array $data
  * @param \NetCore\FileSystem\type|string $sortBy
  * @param \NetCore\FileSystem\type|string $direction
  * @return array
  */
 public static function sort(array $data, $sortBy = 'id', $direction = 'asc')
 {
     $sortFunction = function ($a, $b) use($sortBy, $direction) {
         $methodName = 'get' . StaticConfigurator::toPascalCased($sortBy);
         $aVal = $a->{$methodName}();
         $bVal = $b->{$methodName}();
         if (is_int($aVal) && is_int($bVal)) {
             if ($aVal > $bVal) {
                 return $direction == 'asc' ? 1 : -1;
             } else {
                 if ($aVal < $bVal) {
                     return $direction == 'asc' ? -1 : 1;
                 } else {
                     return 0;
                 }
             }
         }
         if ($direction == 'asc') {
             return strcmp($aVal, $bVal);
         } else {
             return strcmp($aVal, $bVal);
         }
     };
     usort($data, $sortFunction);
     return $data;
 }
 public function setOptions($options = array())
 {
     StaticConfigurator::setOptions($this, $options);
 }