本文整理匯總了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());
}