BcUtil::unserialize PHP Method

unserialize() public static method

アンシリアライズ base64_decode が前提
public static unserialize ( mixed $value ) : mixed
$value mixed 対象文字列
return mixed
    public static function unserialize($value)
    {
        $_value = $value;
        $value = @unserialize(base64_decode($value));
        // 下位互換の為、しばらくの間、失敗した場合の再変換を行う v.3.0.2
        if ($value === false) {
            $value = unserialize($_value);
        }
        return $value;
    }

Usage Example

Example #1
0
 /**
  * ウィジェットエリアを表示する
  *
  * @param $no ウィジェットエリアNO
  * @param array $options オプション
  *  `subDir` (boolean) エレメントのパスについてプレフィックスによるサブディレクトリを追加するかどうか
  *  ※ その他のパラメータについては、View::element() を参照
  */
 public function show($no, $options = array())
 {
     $options = array_merge(array('subDir' => true), $options);
     $WidgetArea = ClassRegistry::init('WidgetArea');
     $widgetArea = $WidgetArea->find('first', array('conditions' => array('WidgetArea.id' => $no)));
     if (empty($widgetArea['WidgetArea']['widgets'])) {
         return;
     }
     $widgets = BcUtil::unserialize($widgetArea['WidgetArea']['widgets']);
     usort($widgets, array('BcWidgetAreaHelper', '_widgetSort'));
     foreach ($widgets as $key => $widget) {
         $key = key($widget);
         if ($widget[$key]['status']) {
             $params = array();
             $plugin = '';
             $params['widget'] = true;
             if (empty($_SESSION['Auth']['User']) && !isset($cache)) {
                 $params['cache'] = '+1 month';
             }
             $params = am($params, $widget[$key]);
             $params[$no . '_' . $widget[$key]['id']] = $no . '_' . $widget[$key]['id'];
             // 同じタイプのウィジェットでキャッシュを特定する為に必要
             if (!empty($params['plugin'])) {
                 $plugin = Inflector::camelize($params['plugin']) . '.';
                 unset($params['plugin']);
             }
             $this->_View->BcBaser->element($plugin . 'widgets/' . $widget[$key]['element'], $params, $options);
         }
     }
 }
All Usage Examples Of BcUtil::unserialize