本文整理汇总了PHP中Symfony\Component\Translation\MessageCatalogue::getResources方法的典型用法代码示例。如果您正苦于以下问题:PHP MessageCatalogue::getResources方法的具体用法?PHP MessageCatalogue::getResources怎么用?PHP MessageCatalogue::getResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Translation\MessageCatalogue
的用法示例。
在下文中一共展示了MessageCatalogue::getResources方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initializeCacheCatalogue
/**
* Initialize filerev catalogue from cache
* or generate cache if not already available
*/
private function initializeCacheCatalogue()
{
if (isset($this->catalogue)) {
return;
}
$debug = $this->container->getParameter('grunt.debug');
$cache = new ConfigCache($this->getCatalogueCachePath(), $debug);
if (!$cache->isFresh()) {
$this->initializeCatalogue();
$content = sprintf(<<<EOF
<?php
use Symfony\\Component\\Translation\\MessageCatalogue;
\$catalogue = new MessageCatalogue(null, %s);
return \$catalogue;
EOF
, var_export($this->catalogue->all(), true));
$cache->write($content, $this->catalogue->getResources());
return;
}
$this->catalogue = (include $cache);
}
示例2: initializeCacheCatalogue
/**
* Initialize filerev catalogue from cache
* or generate cache if not already available
*/
protected function initializeCacheCatalogue()
{
if (isset($this->summary)) {
return;
}
$cache = new ConfigCache($this->getCatalogueCachePath($this->cacheDir), $this->debug);
if (!$cache->isFresh()) {
$this->initializeCatalogue($this->summaryFile);
$content = sprintf(<<<EOF
<?php
use Symfony\\Component\\Translation\\MessageCatalogue;
\$catalogue = new MessageCatalogue(null, %s);
return \$catalogue;
EOF
, var_export($this->summary->all(), true));
$cache->write($content, $this->summary->getResources());
return;
}
$this->summary = (include $cache);
}
示例3: testGetAddResource
public function testGetAddResource()
{
$catalogue = new MessageCatalogue('en');
$r = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
$r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
$catalogue->addResource($r);
$catalogue->addResource($r);
$r1 = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
$catalogue->addResource($r1);
$this->assertEquals(array($r, $r1), $catalogue->getResources());
}
示例4: filterCatalogue
private function filterCatalogue(MessageCatalogue $catalogue, $domain)
{
$filteredCatalogue = new MessageCatalogue($catalogue->getLocale());
if ($messages = $catalogue->all($domain)) {
$filteredCatalogue->add($messages, $domain);
}
foreach ($catalogue->getResources() as $resource) {
$filteredCatalogue->addResource($resource);
}
if ($metadata = $catalogue->getMetadata('', $domain)) {
foreach ($metadata as $k => $v) {
$filteredCatalogue->setMetadata($k, $v, $domain);
}
}
return $filteredCatalogue;
}
示例5: getMatchedResources
/**
* Gets the resources that matches a domain and a locale on a particular catalog
*
* @param MessageCatalogue $catalog the catalog
* @param string $domain the domain name (default is 'messages')
* @param string $locae the locale, to filter fallbackLocale
* @return array of FileResource objects
*/
private function getMatchedResources(MessageCatalogue $catalog, $domain, $locale)
{
$matched = array();
foreach ($catalog->getResources() as $resource) {
// @see Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
// filename is domain.locale.format
$basename = \basename($resource->getResource());
list($resourceDomain, $resourceLocale, $format) = explode('.', $basename);
if ($domain === $resourceDomain && $locale === $resourceLocale) {
$matched[] = $resource;
}
}
return $matched;
}
示例6: testGetAddResource
public function testGetAddResource()
{
if (!class_exists('Symfony\\Component\\Config\\Loader\\Loader')) {
$this->markTestSkipped('The "Config" component is not available');
}
$catalogue = new MessageCatalogue('en');
$r = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
$r->expects($this->any())->method('__toString')->will($this->returnValue('r'));
$catalogue->addResource($r);
$catalogue->addResource($r);
$r1 = $this->getMock('Symfony\\Component\\Config\\Resource\\ResourceInterface');
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
$catalogue->addResource($r1);
$this->assertEquals(array($r, $r1), $catalogue->getResources());
}