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


PHP Definition类代码示例

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


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

示例1: save

    /**
     * Cache a file containing the dispatch list.
     *
     * Serializes the server definition stores the information
     * in $filename.
     *
     * Returns false on any error (typically, inability to write to file), true
     * on success.
     *
     * @param  string $filename
     * @param  \Zend\Server\Server $server
     * @return bool
     */
    public static function save($filename, Server $server)
    {
        if (!is_string($filename)
            || (!file_exists($filename) && !is_writable(dirname($filename))))
        {
            return false;
        }

        $methods = $server->getFunctions();

        if ($methods instanceof Definition) {
            $definition = new Definition();
            foreach ($methods as $method) {
                if (in_array($method->getName(), self::$_skipMethods)) {
                    continue;
                }
                $definition->addMethod($method);
            }
            $methods = $definition;
        }

        if (0 === @file_put_contents($filename, serialize($methods))) {
            return false;
        }

        return true;
    }
开发者ID:niallmccrudden,项目名称:zf2,代码行数:40,代码来源:Cache.php

示例2: add

 /**
  * @param Definition $definition
  */
 public function add(Definition $definition)
 {
     if (!class_exists($definition->getClass())) {
         throw new \InvalidArgumentException(sprintf("Invalid class \"%s\"", $definition->getClass()));
     }
     $this->classes[$definition->getName()] = $definition;
 }
开发者ID:stanlemon,项目名称:rest-bundle,代码行数:10,代码来源:Registry.php

示例3: expects_an_expected_field_in_each_expectation

 /**
  * @test
  */
 public function expects_an_expected_field_in_each_expectation()
 {
     $this->assertException(new \Exception('Missing expected field.'), function () {
         $definitions = array('expectations' => array(array('uri' => 'http://www.example.com', 'type' => 'json')));
         $d = new Definition($definitions);
         $d->getExpectations();
     });
 }
开发者ID:jonjitsu,项目名称:api-tester,代码行数:11,代码来源:DefinitionTest.php

示例4: create

 /**
  * {@inheritdoc}
  */
 public function create($type, $path, array $properties = array())
 {
     $definition = new Definition();
     $definition->setType($type);
     $definition->setPath($path);
     $definition->setProperties($properties);
     return $definition;
 }
开发者ID:aboutcoders,项目名称:file-distribution,代码行数:11,代码来源:DefinitionFactory.php

示例5: createCalendar

/**
 * Creates a matrix with 7 columns, one per day of week, and as many rows (weeks) as necessary.
 * Every cell contains a dictionary with the wotd, the definition and other info.
 */
function createCalendar($year, $month)
{
    $days = listDaysOfMonth($year, $month);
    $today = date('Y-m-d');
    $calendar = array();
    // Pad beginning
    $startDow = date('N', strtotime("{$year}-{$month}-01"));
    for ($i = 1; $i < $startDow; $i++) {
        $calendar[] = array();
    }
    // Create a record per day
    foreach ($days as $i => $date) {
        $wotd = WordOfTheDay::get_by_displayDate($date);
        $wotdr = $wotd ? WordOfTheDayRel::get_by_wotdId($wotd->id) : null;
        $def = $wotdr ? Definition::get_by_id($wotdr->refId) : null;
        $visible = $def && ($date <= $today || util_isModerator(PRIV_WOTD));
        $calendar[] = array('wotd' => $wotd, 'def' => $def, 'visible' => $visible, 'dayOfMonth' => $i + 1);
    }
    // Pad end
    while (count($calendar) % 7 != 0) {
        $calendar[] = array();
    }
    // Wrap 7 records per line
    $weeks = array();
    while (count($calendar)) {
        $weeks[] = array_splice($calendar, 0, 7);
    }
    return $weeks;
}
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:33,代码来源:wotdArchive.php

示例6: smarty_fetchSkin

function smarty_fetchSkin()
{
    $skin = session_getSkin();
    // Set some skin variables based on the skin preferences in the config file.
    // Also assign some skin-specific variables so we don't compute them unless we need them
    $skinVariables = session_getSkinPreferences($skin);
    switch ($skin) {
        case 'zepu':
            $skinVariables['afterSearchBoxBanner'] = true;
            break;
        case 'polar':
            $wordCount = Definition::getWordCount();
            $wordCountRough = $wordCount - $wordCount % 10000;
            smarty_assign('words_total', util_formatNumber($wordCount, 0));
            smarty_assign('words_rough', util_formatNumber($wordCountRough, 0));
            smarty_assign('words_last_month', util_formatNumber(Definition::getWordCountLastMonth(), 0));
            break;
        case 'mobile':
            smarty_assign('words_total', util_formatNumber(Definition::getWordCount(), 0));
            smarty_assign('words_last_month', util_formatNumber(Definition::getWordCountLastMonth(), 0));
            break;
    }
    smarty_assign('skinVariables', $skinVariables);
    smarty_register_outputfilters();
    return $GLOBALS['smarty_theSmarty']->fetch("{$skin}/pageLayout.ihtml");
}
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:26,代码来源:smarty.php

示例7: handle

 public static function handle($uri)
 {
     $definitions = \Definition::all();
     // Polyfill
     if (!function_exists('array_column')) {
         function array_column($array, $column_name)
         {
             return array_map(function ($element) use($column_name) {
                 return $element[$column_name];
             }, $array);
         }
     }
     // Get unique properties
     $keywords = Definitions\KeywordController::getKeywordList($definitions);
     $languages = array_count_values(array_filter(array_column($definitions->toArray(), 'language')));
     $licenses = array_count_values(array_filter(array_column($definitions->toArray(), 'rights')));
     $themes = array_count_values(array_filter(array_column($definitions->toArray(), 'theme')));
     $publishers = array_count_values(array_filter(array_column($definitions->toArray(), 'publisher_name')));
     // Sort by "Popularity"
     // For alphabetical order: use ksort
     arsort($keywords);
     arsort($languages);
     arsort($licenses);
     arsort($themes);
     arsort($publishers);
     $view = \View::make('home')->with('title', 'Datasets | The Datatank')->with('page_title', 'Datasets')->with('keywords', $keywords)->with('languages', $languages)->with('licenses', $licenses)->with('themes', $themes)->with('publishers', $publishers)->with('definitions', $definitions);
     return \Response::make($view);
 }
开发者ID:tdt,项目名称:core,代码行数:28,代码来源:HomeController.php

示例8: deleteByLexemId

 public static function deleteByLexemId($lexemId)
 {
     $ldms = LexemDefinitionMap::get_all_by_lexemId($lexemId);
     foreach ($ldms as $ldm) {
         Definition::updateModDate($ldm->definitionId);
         $ldm->delete();
     }
 }
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:8,代码来源:LexemDefinitionMap.php

示例9: test

 public function test()
 {
     $loader = new ResourceLoader();
     $definitions = new Definition($loader->load($this->source));
     foreach ($definitions->getExpectations() as $definition) {
         if (null !== $definition['type']) {
             $actual = $loader->getType($definition['uri']);
             if ($actual !== $definition['type']) {
                 throw new FailedExpectationException("Type mismatch for {$definition['uri']}. Got [{$actual}] but expected [{$definition['type']}]");
             }
         }
         $expectation = new Expectation($definition['expected']);
         if (!$expectation->assert($loader->load($definition['uri']))) {
             throw new FailedExpectationException(implode("\n", $expectation->getMessages()));
         }
     }
     return true;
 }
开发者ID:jonjitsu,项目名称:api-tester,代码行数:18,代码来源:ExpectationTester.php

示例10: process

 public function process(ContainerBuilder $container)
 {
     $methods = $container->findTaggedServiceIds('knp_rad_prototype.method');
     foreach ($methods as $id => $tags) {
         foreach ($tags as $tag) {
             $tag = array_merge(['alias' => $tag['method'], 'domain' => null], $tag);
             $definition = new Definition('Knp\\Rad\\Prototype\\Prototype\\Method', [sprintf('@%s', $id), $tag['method']]);
             $definition->addTag('knp_rad_prototype.prototype_method', $tag);
             $name = sprintf('knp_rad_prototype.prototype.method.%s', Inflector::tableize($tag['alias']));
             $container->setDefinition($name, $definition);
         }
     }
     $methodContainer = $container->getDefinition('knp_rad_prototype.prototype.container');
     $methods = $container->findTaggedServiceIds('knp_rad_prototype.prototype_method');
     foreach ($methods as $id => $tags) {
         $tag = current($tags);
         $methodContainer->addMethodCall('addMethod', [$tag['alias'], new Reference($id), $tag['domain']]);
     }
 }
开发者ID:knplabs,项目名称:rad-prototype,代码行数:19,代码来源:MethodRegistrationPass.php

示例11: addService

 /**
  * Adds a service
  *
  * @param string $id
  * @param Definition $definition
  * @return string
  */
 private function addService($id, $definition)
 {
     $code = "  {$id}:\n";
     if ($definition->getClass()) {
         $code .= sprintf("    class: %s\n", $definition->getClass());
     }
     $tagsCode = '';
     foreach ($definition->getTags() as $name => $tags) {
         foreach ($tags as $attributes) {
             $att = array();
             foreach ($attributes as $key => $value) {
                 $att[] = sprintf('%s: %s', Yaml::dump($key), Yaml::dump($value));
             }
             $att = $att ? ', ' . implode(' ', $att) : '';
             $tagsCode .= sprintf("      - { name: %s%s }\n", Yaml::dump($name), $att);
         }
     }
     if ($tagsCode) {
         $code .= "    tags:\n" . $tagsCode;
     }
     if ($definition->getFile()) {
         $code .= sprintf("    file: %s\n", $definition->getFile());
     }
     if ($definition->getFactoryMethod()) {
         $code .= sprintf("    factory_method: %s\n", $definition->getFactoryMethod());
     }
     if ($definition->getFactoryService()) {
         $code .= sprintf("    factory_service: %s\n", $definition->getFactoryService());
     }
     if ($definition->getArguments()) {
         $code .= sprintf("    arguments: %s\n", Yaml::dump($this->dumpValue($definition->getArguments()), 0));
     }
     if ($definition->getProperties()) {
         $code .= sprintf("    properties: %s\n", Yaml::dump($this->dumpValue($definition->getProperties()), 0));
     }
     if ($definition->getMethodCalls()) {
         $code .= sprintf("    calls:\n      %s\n", str_replace("\n", "\n      ", Yaml::dump($this->dumpValue($definition->getMethodCalls()), 1)));
     }
     if (ContainerInterface::SCOPE_CONTAINER !== ($scope = $definition->getScope())) {
         $code .= sprintf("    scope: %s\n", $scope);
     }
     if ($callable = $definition->getConfigurator()) {
         if (is_array($callable)) {
             if (is_object($callable[0]) && $callable[0] instanceof Reference) {
                 $callable = array($this->getServiceCall((string) $callable[0], $callable[0]), $callable[1]);
             } else {
                 $callable = array($callable[0], $callable[1]);
             }
         }
         $code .= sprintf("    configurator: %s\n", Yaml::dump($callable, 0));
     }
     return $code;
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:60,代码来源:YamlDumper.php

示例12: __construct

 /**
  * __construct() - For concrete implementation of Zend_Db_Table
  *
  * @param string|array $config string can reference a \Zend\Registry key for a db adapter
  *                             OR it can reference the name of a table
  * @param array|\Zend\Db\Table\Definition $definition
  */
 public function __construct($config = array(), $definition = null)
 {
     if ($definition !== null && is_array($definition)) {
         $definition = new Definition($definition);
     }
     if (is_string($config)) {
         if (\Zend\Registry::isRegistered($config)) {
             trigger_error(__CLASS__ . '::' . __METHOD__ . '(\'registryName\') is not valid usage of Zend_Db_Table, ' . 'try extending Zend_Db_Table_Abstract in your extending classes.', E_USER_NOTICE);
             $config = array(self::ADAPTER => $config);
         } else {
             // process this as table with or without a definition
             if ($definition instanceof Definition && $definition->hasTableConfig($config)) {
                 // this will have DEFINITION_CONFIG_NAME & DEFINITION
                 $config = $definition->getTableConfig($config);
             } else {
                 $config = array(self::NAME => $config);
             }
         }
     }
     parent::__construct($config);
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:28,代码来源:Table.php

示例13: getSourcesForLexem

function getSourcesForLexem($lexem)
{
    global $SOURCES;
    $defs = Definition::loadByLexemId($lexem->id);
    $sources = array();
    foreach ($defs as $def) {
        $shortName = $SOURCES[$def->sourceId]->shortName;
        if (!in_array($shortName, $sources)) {
            $sources[] = $shortName;
        }
    }
    return '(' . implode(',', $sources) . ')';
}
开发者ID:florinp,项目名称:dexonline,代码行数:13,代码来源:mergePlantFamilies.php

示例14: testDeleteApi

 public function testDeleteApi()
 {
     // Delete the published definition for each test csv file.
     foreach ($this->test_data as $file) {
         $this->updateRequest('DELETE');
         $controller = \App::make('Tdt\\Core\\Definitions\\DefinitionController');
         $response = $controller->handle("csv/{$file}");
         $this->assertEquals(200, $response->getStatusCode());
     }
     // Check if everything is deleted properly.
     $definitions_count = \Definition::all()->count();
     $csv_count = \CsvDefinition::all()->count();
     $this->assertTrue($csv_count == 0);
     $this->assertTrue($definitions_count == 0);
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:15,代码来源:CsvTest.php

示例15: createDefinitions

 private function createDefinitions()
 {
     $definitionList = $this->document->getElementsByTagName('definition');
     foreach ($definitionList as $definition) {
         if ($definition->hasChildNodes()) {
             $definitionChildrenNode = $definition->childNodes;
             $definitionObj = new Definition();
             foreach ($definitionChildrenNode as $definitionChild) {
                 if ($definitionChild->nodeName == "name") {
                     $definitionName = $definitionChild->nodeValue;
                     $definitionObj->setName($definitionName);
                 }
                 if ($definitionChild->nodeName == "base") {
                     $definitionObj->setBase($definitionChild->nodeValue);
                 }
                 if ($definitionChild->nodeName == "put") {
                     $pageKey = "";
                     $value = "";
                     $role = "";
                     if ($definitionChild->hasAttribute('pageKey')) {
                         $pageKey = $definitionChild->getAttribute('pageKey');
                     }
                     if ($definitionChild->hasAttribute('value')) {
                         $value = $definitionChild->getAttribute('value');
                     }
                     if ($definitionChild->hasAttribute('role')) {
                         $role = $definitionChild->getAttribute('role');
                     }
                     $put = new Put($pageKey, $value, $role);
                     $definitionObj->addPut($put);
                 }
             }
             $this->addDefinition($definitionName, $definitionObj);
         }
     }
 }
开发者ID:rodrigoprestesmachado,项目名称:whiteboard,代码行数:36,代码来源:PageDefinitionDom.php


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