当前位置: 首页>>代码示例>>PHP>>正文


PHP Fx::dig方法代码示例

本文整理汇总了PHP中Floxim\Floxim\System\Fx::dig方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::dig方法的具体用法?PHP Fx::dig怎么用?PHP Fx::dig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Floxim\Floxim\System\Fx的用法示例。


在下文中一共展示了Fx::dig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveVar

 public function saveVar($input)
 {
     $result = array();
     if (isset($input['page_id'])) {
         fx::env('page_id', $input['page_id']);
     }
     $ib = fx::data('infoblock', $input['infoblock']['id']);
     if ($ib->isLayout()) {
         $root_ib = $ib->getRootInfoblock();
         $ib_visual = $root_ib->getVisual();
     } elseif ($visual_id = fx::dig($input, 'infoblock.visual_id')) {
         $ib_visual = fx::data('infoblock_visual', $visual_id);
     } else {
         $ib_visual = $ib->getVisual();
     }
     // group vars by type to process content vars first
     // because we need content id for 'content-visual' vars on adding a new entity
     $vars = fx::collection($input['vars'])->apply(function ($v) {
         if ($v['var']['type'] == 'livesearch' && !$v['value']) {
             $v['value'] = array();
         }
     })->group(function ($v) {
         return $v['var']['var_type'];
     });
     $contents = fx::collection();
     $new_entity = null;
     if (isset($input['new_entity_props'])) {
         $new_props = $input['new_entity_props'];
         $new_com = fx::component($new_props['type']);
         $new_entity = fx::content($new_props['type'])->create($new_props);
         $contents['new@' . $new_com['id']] = $new_entity;
         // we are working with linker and user pressed "add new" button to create linked entity
         if (isset($input['create_linked_entity'])) {
             $linked_entity_com = fx::component($input['create_linked_entity']);
             $linked_entity = fx::content($linked_entity_com['keyword'])->create();
             $contents['new@' . $linked_entity_com['id']] = $linked_entity;
             // bind the new entity to the linker prop
             if (isset($new_props['_link_field'])) {
                 $link_field = $new_com->getFieldByKeyword($new_props['_link_field'], true);
                 $target_prop = $link_field['format']['prop_name'];
                 $new_entity[$target_prop] = $linked_entity;
             }
         }
     }
     if (isset($vars['content'])) {
         $content_groups = $vars['content']->group(function ($v) {
             $vid = $v['var']['content_id'];
             if (!$vid) {
                 $vid = 'new';
             }
             return $vid . '@' . $v['var']['content_type_id'];
         });
         foreach ($content_groups as $content_id_and_type => $content_vars) {
             list($content_id, $content_type_id) = explode("@", $content_id_and_type);
             if ($content_id !== 'new') {
                 $c_content = fx::content($content_type_id, $content_id);
                 if (!$c_content) {
                     continue;
                 }
                 $contents[$content_id_and_type] = $c_content;
             }
             $vals = array();
             foreach ($content_vars as $var) {
                 $vals[$var['var']['name']] = $var['value'];
             }
             if (isset($contents[$content_id_and_type])) {
                 $contents[$content_id_and_type]->setFieldValues($vals, array_keys($vals));
             } else {
                 fx::log('Content not found in group', $contents, $content_id, $vals);
             }
         }
     }
     $new_id = false;
     $result['saved_entities'] = array();
     foreach ($contents as $cid => $c) {
         try {
             $c->save();
             $result['saved_entities'][] = $c->get();
             if ($cid == 'new') {
                 $new_id = $c['id'];
             }
         } catch (\Exception $e) {
             $result['status'] = 'error';
             if ($e instanceof \Floxim\Floxim\System\Exception\EntityValidation) {
                 $result['errors'] = $e->toResponse();
             }
             break;
         }
     }
     if (isset($vars['visual'])) {
         foreach ($vars['visual'] as $c_var) {
             $var = $c_var['var'];
             $value = $c_var['value'];
             $var['id'] = preg_replace("~\\#new_id\\#\$~", $new_id, $var['id']);
             $visual_set = $var['template_is_wrapper'] ? 'wrapper_visual' : 'template_visual';
             if ($value == 'null') {
                 $value = null;
             }
             $c_visual = $ib_visual[$visual_set];
             if (!is_array($c_visual)) {
//.........这里部分代码省略.........
开发者ID:piarsonforked,项目名称:floxim,代码行数:101,代码来源:Infoblock.php

示例2: isAvailableOnPage

 public function isAvailableOnPage($page)
 {
     if ($this['site_id'] != $page['site_id']) {
         return;
     }
     if ($page->hasVirtualPath()) {
         $ids = $page->getPath()->getValues('id');
     } else {
         $ids = $page->getParentIds();
     }
     $ids[] = $page['id'];
     $ids[] = 0;
     // root
     if (!in_array($this['page_id'], $ids)) {
         return false;
     }
     // if page_id=0 blunt - all pages, ignored by the filter scope.pages
     if ($this['page_id'] != 0) {
         // scope - "this page only"
         if (fx::dig($this, 'scope.pages') == 'this' && $this['page_id'] != $page['id']) {
             return false;
         }
         // scope - "this level, and we look parent
         if (fx::dig($this, 'scope.pages') == 'children' && $this['page_id'] == $page['id']) {
             return false;
         }
     }
     // check for compliance with the filter type page
     $scope_page_type = fx::dig($this, 'scope.page_type');
     if ($scope_page_type && fx::getComponentFullName($scope_page_type) != fx::getComponentFullName($page['type'])) {
         return false;
     }
     return true;
 }
开发者ID:piarsonforked,项目名称:floxim,代码行数:34,代码来源:Entity.php

示例3: getRouter

 /**
  * Get the option router by name
  * fx::router('front')
  */
 public function getRouter($router_name)
 {
     $class = 'Floxim\\Floxim\\Router\\' . ucfirst($router_name);
     return fx::dig($this->routers, $class . '.router');
 }
开发者ID:piarsonforked,项目名称:floxim,代码行数:9,代码来源:Manager.php


注:本文中的Floxim\Floxim\System\Fx::dig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。