Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function sanitize($input)
 {
     if (!is_string($input)) {
         return $input;
     }
     return Serialize::unserialize($input, false);
 }
Ejemplo n.º 2
0
 /**
  * Unserialize.
  *
  * @param string $value serialized array
  * @param array $params params:
  *
  * - key
  * - separator
  *
  * @return string
  */
 public static function unserialize($value, array $params)
 {
     if (empty($value)) {
         return null;
     }
     if (!empty($params['key'])) {
         return ArrayHelper::getValue(Serialize::unserialize($value, false), explode(Helper::getValue($params['separator'], '.'), $params['key']));
     }
     return Serialize::unserialize($value, false);
 }
Ejemplo n.º 3
0
Archivo: RBAC.php Proyecto: romeoz/rock
 /**
  * @param string $itemName
  * @return Item
  * @throws RBACException
  */
 protected function processData($itemName)
 {
     if (empty(static::$items[$itemName]['data'])) {
         throw new RBACException(RBACException::NOT_DATA_PARAMS);
     }
     $data = static::$items[$itemName]['data'];
     if (is_string($data)) {
         $data = Serialize::unserialize($data);
     }
     if ($data instanceof Item) {
         $data->name = $itemName;
         return $data;
     }
     throw new RBACException(RBACException::UNKNOWN_TYPE, ['name' => serialize($data)]);
 }
Ejemplo n.º 4
0
 /**
  * Unserialize value.
  * @param $value
  * @return mixed
  */
 protected function unserialize($value)
 {
     return Serialize::unserialize($value, false);
 }
Ejemplo n.º 5
0
 /**
  * Convert object to multi-array (recursive).
  *
  * @param mixed $value current object
  * @param array $only list of items whose value needs to be returned.
  * @param array $exclude list of items whose value should NOT be returned.
  * @param bool $unserialize
  * @return array
  */
 public static function toArray($value, array $only = [], array $exclude = [], $unserialize = false)
 {
     if (is_array($value)) {
         return static::map($value, function ($value) use($only, $exclude, $unserialize) {
             return static::toArray($value, $only, $exclude, $unserialize);
         }, true);
     }
     if (is_object($value) && !$value instanceof \Closure) {
         if ($value instanceof Arrayable) {
             $attributes = $value->toArray($only, $exclude);
         } else {
             $attributes = $value instanceof \stdClass && isset($value->scalar) ? $value->scalar : get_object_vars($value);
         }
         if (is_array($attributes)) {
             return static::toArray($attributes, $only, $exclude, $unserialize);
         }
         $value = $attributes;
     }
     return $unserialize === true ? Serialize::unserialize($value, false) : $value;
 }