• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Definition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: tearDownAfterClass

 /**
  * Delete everything out of our testing database.
  */
 public static function tearDownAfterClass()
 {
     parent::tearDownAfterClass();
     \Definition::truncate();
     \CsvDefinition::truncate();
     \InstalledDefinition::truncate();
     \JsonDefinition::truncate();
     \ShpDefinition::truncate();
     \SparqlDefinition::truncate();
     \XlsDefinition::truncate();
     \XmlDefinition::truncate();
     \GeoProperty::truncate();
     \TabularColumns::truncate();
     \Geoprojection::truncate();
 }
开发者ID:jalbertbowden,项目名称:core,代码行数:18,代码来源:TestCase.php


示例17: createLexemDefinitionMap

function createLexemDefinitionMap()
{
    LexemDefinitionMap::deleteAll();
    $dbResult = db_selectAllConcepts();
    print "Migrating " . mysql_num_rows($dbResult) . " concepts...\n";
    $seen = 0;
    while ($dbRow = mysql_fetch_assoc($dbResult)) {
        $concept = new Concept();
        $concept->populateFromDbRow($dbRow);
        $words = Word::loadByConceptId($concept->id);
        $definitions = Definition::loadByConceptId($concept->id);
        if ($definitions) {
            // Select distinct words
            $distinctWords = array();
            foreach ($words as $word) {
                $distinctWords[$word->name] = 1;
            }
            // For every word, look up all the lexems. Then map each of those lexems
            // to every definition.
            foreach ($distinctWords as $word => $ignored) {
                $lexems = Lexem::loadByUnaccented($word);
                // Create lexem if necessary so that we don't lose any words during the
                // migration
                if (count($lexems) == 0) {
                    $lexem = Lexem::create($word, 'T', 1, '');
                    $lexem->save();
                    $lexem->id = db_getLastInsertedId();
                    $lexems[] = $lexem;
                    $lexem->regenerateParadigm();
                }
                foreach ($lexems as $lexem) {
                    foreach ($definitions as $definition) {
                        $ldm = LexemDefinitionMap::load($lexem->id, $definition->id);
                        if (!$ldm) {
                            $ldm = LexemDefinitionMap::create($lexem->id, $definition->id);
                            $ldm->save();
                        }
                    }
                }
            }
        }
        $seen++;
        if ($seen % 1000 == 0) {
            print "Seen: {$seen};\n";
        }
    }
    print "Seen: {$seen};\n";
}
开发者ID:florinp,项目名称:dexonline,代码行数:48,代码来源:migration.php


示例18: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('definitions', function ($table) {
         $table->string('title', 255);
     });
     // Denormalize the definitions by copying the existing titles and descriptions
     foreach (\Definition::all() as $definition) {
         $source_model = new $definition->source_type();
         $source = $source_model->find($definition->source_id);
         if (!empty($source->title)) {
             $definition->title = $source->title;
         }
         if (!empty($source->description)) {
             $definition->description = $source->description;
         }
         $definition->save();
     }
 }
开发者ID:tdt,项目名称:core,代码行数:23,代码来源:2016_03_05_100154_denormalize_title_and_description_metadata.php


示例19: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('definition_facet_types', function ($table) {
         $table->increments('id');
         $table->string('facet_name', 255);
     });
     $facet_types = ['rights', 'keyword', 'language', 'theme', 'publisher_name'];
     $facet_type_models = [];
     foreach ($facet_types as $facet) {
         $facet_type = \FacetType::create(['facet_name' => $facet]);
         $facet_type->save();
         if ($facet != 'keyword') {
             $facet_type_model[$facet] = $facet_type;
         } else {
             $facet_type_model['keywords'] = $facet_type;
         }
     }
     Schema::create('definition_facets', function ($table) {
         $table->increments('id');
         $table->integer('definition_id');
         $table->integer('facet_id');
         $table->string('facet_name');
         $table->string('value');
     });
     // Copy all of the facet related info to the new definition_facets table
     $definitions = \Definition::all();
     foreach ($definitions as $definition) {
         foreach ($facet_type_models as $facet_name => $facet_type) {
             if ($facet_name != 'keywords' && !empty($definition->{$facet_name})) {
                 $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => $facet_name, 'value' => $definition->{$facet_name}]);
                 $facet->save();
             } else {
                 // split the keywords
                 if (!empty($definition->keywords)) {
                     $keywords = explode(',', $definition->keywords);
                     foreach ($keywords as $keyword) {
                         $facet = \Facet::create(['definition_id' => $definition->id, 'facet_id' => $facet_type->id, 'facet_name' => 'keyword', 'value' => $keyword]);
                         $facet->save();
                     }
                 }
             }
         }
     }
 }
开发者ID:tdt,项目名称:core,代码行数:49,代码来源:2016_04_06_144510_add_faceting_tables.php


示例20: parseOneDefinition

 /** Parses one definition line, i.e. extracts {{label}}, definition,
  * {{example|Quotation sentence.}}, creates and fills a meaning (WMeaning).
  * @param page_title    word which is described in this article 'text'
  * @param lang_section  language of this section of an article
  * @param line          definition line
  * @return WMeaning or null if the line is not started from "#" or = "# "
  */
 public static function parseOneDefinition($page_title, $lang_section, $line)
 {
     if (preg_match("/\\{\\{Нужен перевод\\}\\}/", $line)) {
         return null;
     }
     // remove empty quotations: {{пример|}} and {{пример}}
     $line = preg_replace("/\\{\\{пример\\|\\}\\}/", "", $line);
     $line = preg_replace("/\\{\\{пример\\}\\}/", "", $line);
     $line = preg_replace("/\\{\\{пример перевод\\|\\}\\}/", "", $line);
     // todo check - does exist this example
     $line = preg_replace("/\\[\\[\\]\\]/", "", $line);
     // empty definition
     $line = Definition::stripNumberSign($page_title, $line);
     if (0 == strlen($line)) {
         return null;
     }
     if (preg_match("/\\A\\{\\{морфема/", $line)) {
         return null;
     }
     // skip now, todo (parse) in future
     $label_text = LabelRu . extractLabelsTrimText(line);
     if (null == label_text) {
         return null;
     }
     /*
             $line = label_text.getText();
             
             // 2. extract text till first {{пример|
             String wiki_definition = WQuoteRu.getDefinitionBeforeFirstQuote(page_title, line);
     
             // 3. parsing wiki-text
             //StringBuffer definition = WikiWord.parseDoubleBrackets(page_title, new StringBuffer(wiki_definition));
     
             // 4. extract wiki-links (internal links)
             //WikiWord[] ww = WikiWord.getWikiWords(page_title, new StringBuffer(wiki_definition));
     
             // 5. extract quotations
             WQuote[] quote = WQuoteRu.getQuotes(page_title, line);        
     
             return new WMeaning(page_title, label_text.getLabels(), wiki_definition, quote, false);
     */
 }
开发者ID:stasonmokoron,项目名称:nerpa,代码行数:49,代码来源:WMeaning.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Department类代码示例发布时间:2022-05-23
下一篇:
PHP DeferredUpdates类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap