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


PHP arr::search_collection方法代码示例

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


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

示例1: customValidation

 public static function customValidation()
 {
     $base = Event::$data;
     if (!$base or !$base instanceof Number) {
         return TRUE;
     }
     $base['number'] = trim($base['number']);
     // Get the list of NumberContexts, the generic save will have added
     // all contexts in this list but we need to filter invalids (0) and
     // unassignments
     if (!($assigned_contexts = arr::get($_POST, 'number', 'NumberContext'))) {
         $assigned_contexts = array();
     }
     // Loop each of the number contexts remove those that are not in the
     // post'd list or invalid (context_id == 0)
     foreach ($base->NumberContext as $pos => $context) {
         if (empty($context['context_id']) or !arr::search_collection($assigned_contexts, 'context_id', $context['context_id'])) {
             unset($base->NumberContext[$pos]);
         }
     }
     // If there are no contexts left...
     if (!$base->NumberContext->count()) {
         // see if there are more than one on this account, because if there
         // is only one then we know which to assign it to ;)
         $contexts = Doctrine::getTable('NumberContext')->findAll();
         if ($contexts->count() == 1) {
             $base->NumberContext[] = $contexts[0];
         } else {
             // sorry we tried... what do you want to do?
             throw new Exception('Please assign this number to at least one context');
         }
     }
     if (!($assigned_pool = arr::get($_POST, 'number', 'NumberPool'))) {
         $assigned_pool = array();
     }
     foreach ($base->NumberPool as $pos => $pool) {
         if (empty($pool['number_type_id']) or !arr::search_collection($assigned_pool, 'number_type_id', $pool['number_type_id'])) {
             unset($base->NumberPool[$pos]);
         }
     }
     if (!empty($base['class_type'])) {
         $numberType = Doctrine::getTable('NumberType')->findOneByClass($base['class_type']);
         if ($number_type_id = arr::get($numberType, 'number_type_id')) {
             if (!arr::search_collection($base->NumberPool, 'number_type_id', $number_type_id)) {
                 $numberPool = new NumberPool();
                 $numberPool['number_type_id'] = $number_type_id;
                 $base->NumberPool[] = $numberPool;
             }
         } else {
             kohana::log('error', $base['class_type'] . ' submitted but there is no such pool type!');
             throw new Exception('Number does not belong to a number pool matching the destination');
         }
     }
     if (!$base->NumberPool->count()) {
         throw new Exception('Please assign this number to at least one number pool');
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:57,代码来源:Numbers.php

示例2: foreach

        <ul>

            <?php 
    foreach ($contexts as $context_id => $name) {
        ?>

                <li>

                    <div class="field">

                        <?php 
        echo form::label('context_' . $context_id, $name);
        ?>

                        <?php 
        echo form::checkbox(array('name' => 'number[NumberContext][][context_id]', 'id' => 'context_' . $context_id, 'class' => 'number_context_option'), $context_id, (bool) arr::search_collection($number['NumberContext'], 'context_id', $context_id));
        ?>

                    </div>

                </li>

            <?php 
    }
    ?>

        </ul>

    <?php 
    echo form::close_section();
    ?>
开发者ID:swk,项目名称:bluebox,代码行数:31,代码来源:numberContexts.php

示例3: foreach

    <ul>

        <?php 
foreach ($numberTypes['numberTypes'] as $numberType) {
    ?>

            <li>

                <div class="field">

                    <?php 
    echo form::label('numberType_' . $numberType['number_type_id'], inflector::humanizeModelName(str_replace('Number', '', $numberType['class'])));
    ?>

                    <?php 
    echo form::checkbox(array('name' => 'number[NumberPool][][number_type_id]', 'id' => 'numberType_' . $numberType['number_type_id']), $numberType['number_type_id'], (bool) arr::search_collection($number['NumberPool'], 'number_type_id', $numberType['number_type_id']));
    ?>

                </div>

            </li>

        <?php 
}
?>

    </ul>

<?php 
echo form::close_section();
开发者ID:swk,项目名称:bluebox,代码行数:30,代码来源:numberPools.php


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