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


PHP Library::import方法代码示例

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


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

示例1: addRouteRecursively

 /**
  * The recursive method powering addRouteFor(Request).
  * 
  * @param array Part of a path in reverse order.
  * @param int Current index of path part array - decrements with each step.
  * @param Route The route being added
  * 
  * @return FindRouteResult
  */
 private function addRouteRecursively(&$pathParts, $index, $route)
 {
     // Base Case
     if ($index < 0) {
         foreach ($route->methods as $method) {
             if (isset($this->m[$method])) {
                 Library::import('recess.framework.routing.DuplicateRouteException');
                 throw new DuplicateRouteException($method . ' ' . str_replace('//', '/', $route->path), $route->fileDefined, $route->lineDefined);
             }
             $this->m[$method] = new Rt($route);
         }
         return;
     }
     $nextPart = $pathParts[$index];
     if ($nextPart[0] != '$') {
         $childrenArray =& $this->s;
         $nextKey = $nextPart;
         $isParam = false;
     } else {
         $childrenArray =& $this->p;
         $nextKey = substr($nextPart, 1);
         $isParam = true;
     }
     if (!isset($childrenArray[$nextKey])) {
         $child = new RtNode();
         if ($isParam) {
             $child->c = $nextKey;
         }
         $childrenArray[$nextKey] = $child;
     } else {
         $child = $childrenArray[$nextKey];
     }
     $child->addRouteRecursively($pathParts, $index - 1, $route);
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:43,代码来源:RtNode.class.php

示例2: modelToTableDescriptor

 /**
  * Transform a model descriptor to a table descriptor.
  *
  * @param ModelDescriptor $descriptor
  * @return RecessTableDescriptor
  */
 function modelToTableDescriptor(ModelDescriptor $descriptor)
 {
     Library::import('recess.database.pdo.RecessTableDescriptor');
     Library::import('recess.database.pdo.RecessColumnDescriptor');
     $tableDescriptor = new RecessTableDescriptor();
     $tableDescriptor->name = $descriptor->getTable();
     foreach ($descriptor->properties as $property) {
         $tableDescriptor->addColumn($property->name, $property->type, true, $property->isPrimaryKey, array(), $property->isAutoIncrement ? array('autoincrement' => true) : array());
     }
     return $tableDescriptor;
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:17,代码来源:ModelDataSource.class.php

示例3: loadHelper

 /**
  * Import and (as required) initialize helpers for use in the view.
  * Helper is the path and name of a class as used by Library::import().
  * For multiple helpers, pass a single array of helpers or use multiple arguments.
  * 
  * @param $helper
  */
 public function loadHelper($helper)
 {
     $helpers = is_array($helper) ? $helper : func_get_args();
     foreach ($helpers as $helper) {
         Library::import($helper);
         $init = array(Library::getClassName($helper), 'init');
         if (is_callable($init)) {
             call_user_func($init, $this);
         }
     }
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:18,代码来源:AbstractView.class.php

示例4: getTableDescriptor

 /**
  * Retrieve the a table's RecessTableDescriptor.
  *
  * @param string $table Name of table.
  * @return RecessTableDescriptor
  */
 function getTableDescriptor($table)
 {
     Library::import('recess.database.pdo.RecessTableDescriptor');
     $tableDescriptor = new RecessTableDescriptor();
     $tableDescriptor->name = $table;
     try {
         $results = $this->pdo->query('SHOW COLUMNS FROM ' . $table . ';');
         $tableDescriptor->tableExists = true;
     } catch (PDOException $e) {
         $tableDescriptor->tableExists = false;
         return $tableDescriptor;
     }
     foreach ($results as $result) {
         $tableDescriptor->addColumn($result['Field'], $this->getRecessType($result['Type']), $result['Null'] == 'NO' ? false : true, $result['Key'] == 'PRI' ? true : false, $result['Default'] == null ? '' : $result['Default'], $result['Extra'] == 'auto_increment' ? array('autoincrement' => true) : array());
     }
     return $tableDescriptor;
 }
开发者ID:KrisJordan,项目名称:recess,代码行数:23,代码来源:MysqlDataSourceProvider.class.php

示例5: getAnnotations

 function getAnnotations()
 {
     Library::import('recess.lang.Annotation');
     $docstring = $this->getDocComment();
     if ($docstring == '') {
         return array();
     } else {
         $returns = array();
         try {
             $returns = Annotation::parse($docstring);
         } catch (InvalidAnnotationValueException $e) {
             throw new InvalidAnnotationValueException('In class "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getFileName(), $this->getStartLine(), array());
         } catch (UnknownAnnotationException $e) {
             throw new UnknownAnnotationException('In class "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getFileName(), $this->getStartLine(), array());
         }
     }
     return $returns;
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:18,代码来源:RecessReflectionClass.class.php

示例6: __construct

<?php

Library::import('recess.framework.Application');
class WelcomeApplication extends Application
{
    public function __construct()
    {
        $this->name = 'Welcome to Recess (GC)';
        $this->viewsDir = $_ENV['dir.apps'] . 'welcome/views/';
        $this->modelsPrefix = 'welcome.models.';
        $this->controllersPrefix = 'welcome.controllers.';
        $this->routingPrefix = '/';
        $this->assetUrl = 'recess/recess/apps/tools/public/';
    }
}
开发者ID:GianlucaCollot,项目名称:recess,代码行数:15,代码来源:WelcomeApplication.class.php

示例7: isFor

 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
Library::import('recess.lang.Annotation');
class LabelAnnotation extends Annotation
{
    public function isFor()
    {
        return Annotation::FOR_PROPERTY;
    }
    public function usage()
    {
        return '!Label "Column Label"';
    }
    public function expand($class, $reflection, $descriptor)
    {
        $propertyName = $reflection->getName();
        if (isset($descriptor->properties[$propertyName])) {
            $property =& $descriptor->properties[$propertyName];
开发者ID:KrisJordan,项目名称:Recess-Framework-Model-Validations,代码行数:31,代码来源:LabelAnnotation.class.php

示例8: render

<?php

Library::import('recess.framework.forms.FormInput');
class PasswordInput extends FormInput
{
    function render()
    {
        echo '<input type="password" name="', $this->name, '"', ' id="' . $this->name . '"';
        if ($this->class != '') {
            echo ' class="', $this->class, '"';
        }
        if ($this->value != '') {
            echo ' value="', $this->value, '"';
        }
        echo ' />';
    }
}
?>

开发者ID:rday,项目名称:recess,代码行数:18,代码来源:PasswordInput.class.php

示例9:

 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
Library::import('ValidationPlugin.annotations.ValidatesAnnotation');
Library::import('ValidationPlugin.wrappers.ValidatesPresenceOfWrapper');
//
// ValidatesPresenceOf
//
// This annotation adds a validator to a Model class that ensures
// the specified fields' values are set and not empty.
//
// USAGE:
//
// /**
//  * !ValidatesPresenceOf Fields: (title, author), On: (save, insert, update)
//  */
// class Book extends Model {
//		public $title;
// 		public $author;
// }
开发者ID:KrisJordan,项目名称:Recess-Framework-Model-Validations,代码行数:31,代码来源:ValidatesPresenceOfAnnotation.class.php

示例10: index

<?php

Library::import('recess.framework.controllers.Controller');
/**
 * !RespondsWith Layouts
 * !Prefix Views: home/, Routes: /
 */
class IconHarvesterHomeController extends Controller
{
    /** !Route GET */
    function index()
    {
        $this->redirect('ThemeController::index');
    }
}
开发者ID:ratz,项目名称:icon-harvester,代码行数:15,代码来源:IconHarvesterHomeController.class.php

示例11:

<?php

Library::import('recess.database.sql.ISqlSelectOptions');
Library::import('recess.database.sql.ISqlConditions');
/**
 * PdoDataSet is used as a proxy to query results that is realized once the results are
 * iterated over or accessed using array notation. Queries can thus be built incrementally
 * and an SQL request will only be issued once needed.
 *  
 * Example usage:
 * 
 * $results = new PdoDataSet(Databases::getDefault());
 * $results->from('tableName')->equal('someColumn', 'Hi')->limit(10)->offset(50);
 * foreach($results as $result) { // This is when the query is run!
 * 		print_r($result);
 * }
 * 
 * @author Kris Jordan <krisjordan@gmail.com>
 * @copyright 2008, 2009 Kris Jordan
 * @package Recess PHP Framework
 * @license MIT
 * @link http://www.recessframework.org/
 */
class PdoDataSet implements Iterator, Countable, ArrayAccess, ISqlSelectOptions, ISqlConditions
{
    /**
     * The SqlBuilder instance we use to build up the query string.
     *
     * @var SqlBuilder
     */
    protected $sqlBuilder;
开发者ID:rday,项目名称:recess,代码行数:31,代码来源:PdoDataSet.class.php

示例12: callMe

<?php

require_once 'PHPUnit/Framework.php';
Library::import('recess.lang.Object');
class MyObject extends Object
{
}
class MyNewClassMethodProvider
{
    function callMe()
    {
        return 'Hello World!';
    }
}
class ObjectTest extends PHPUnit_Framework_TestCase
{
    function testAttachedMethod()
    {
        $myObject = new MyObject();
        try {
            $this->assertEquals('Hello World!', $myObject->helloWorld());
            $this->hasFailed();
        } catch (RecessException $e) {
            // Success
        }
        $attachedMethodProvider = new MyNewClassMethodProvider();
        MyObject::attachMethod('MyObject', 'helloWorld', $attachedMethodProvider, 'callMe');
        try {
            $this->assertEquals($myObject->helloWorld(), 'Hello World!');
            // Success
        } catch (RecessException $e) {
开发者ID:amitshukla30,项目名称:recess,代码行数:31,代码来源:ObjectTest.php

示例13: toCode

<?php

Library::import('recess.lang.codegen.CodeGenClassMember');
/**
 * @author Kris Jordan <krisjordan@gmail.com>
 * @copyright 2008, 2009 Kris Jordan
 * @package Recess PHP Framework
 * @license MIT
 * @link http://www.recessframework.org/
 */
class CodeGenMethod extends CodeGenClassMember
{
    function toCode($blockIndent = '')
    {
        $code = $this->doccomment->toCode();
        $method;
        if ($this->accessLevel != CodeGen::PUB) {
            $method = $this->accessLevel;
        }
        if ($method != '') {
            $method .= ' ';
        }
        if ($this->isStatic) {
            $method .= CodeGen::STAT;
        }
        if ($method != '') {
            $method .= ' ';
        }
        $method .= 'function ' . $this->name . ' {};';
        $code .= $method;
        return $code;
开发者ID:amitshukla30,项目名称:recess,代码行数:31,代码来源:CodeGenMethod.class.php

示例14:

 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
Library::import('recesss.lang.Annotation');
Library::import('PaginationPlugin.models.PaginatorDelegate');
/**
 * Pagination Annotation
 *
 * This annotation attaches the paginate() method to a Model object.
 *
 * USAGE:
 *
 * !Paginate Limit: 5
 *
 * Limit:
 * - Optional
 * - Determines the number of results to show per page
 *
 * @author Josh Lockhart <info@joshlockhart.com>
 * @since Verson 1.0
开发者ID:KrisJordan,项目名称:Recess-Framework-Model-Pagination,代码行数:31,代码来源:PaginateAnnotation.class.php

示例15: analyzeModelName

 /** !Route GET, model/gen/analyzeModelName/$modelName */
 public function analyzeModelName($modelName)
 {
     Library::import('recess.lang.Inflector');
     $this->tableName = Inflector::toPlural(Inflector::toUnderscores($modelName));
     $this->isValid = preg_match('/^[a-zA-Z][_a-zA-z0-9]*$/', $modelName) == 1;
 }
开发者ID:KrisJordan,项目名称:recess,代码行数:7,代码来源:RecessToolsAppsController.class.php


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