本文整理汇总了PHP中Symfony\Component\HttpKernel\KernelInterface::locateResource方法的典型用法代码示例。如果您正苦于以下问题:PHP KernelInterface::locateResource方法的具体用法?PHP KernelInterface::locateResource怎么用?PHP KernelInterface::locateResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpKernel\KernelInterface
的用法示例。
在下文中一共展示了KernelInterface::locateResource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: open
/**
* Get a manipulable image instance.
*
* @param string $file the image path
*
* @return ImageHandler a manipulable image instance
*/
public function open($file)
{
if (strlen($file) >= 1 && $file[0] == '@') {
$file = $this->fileLocator instanceof FileLocatorInterface ? $this->fileLocator->locate($file) : $this->fileLocator->locateResource($file);
}
return $this->createInstance($file);
}
示例2: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$configFile = $this->kernel->locateResource('@OroFormBundle/Resources/config/config_icon.yml');
$config = Yaml::parse($configFile);
$choices = array_flip($config['oro_icon_select']);
$resolver->setDefaults(['placeholder' => 'oro.form.choose_value', 'choices' => $choices, 'empty_value' => '', 'configs' => ['placeholder' => 'oro.form.choose_value', 'result_template_twig' => 'OroFormBundle:Autocomplete:icon/result.html.twig', 'selection_template_twig' => 'OroFormBundle:Autocomplete:icon/selection.html.twig']]);
}
示例3: onPreUp
/**
* @param PreMigrationEvent $event
*/
public function onPreUp(PreMigrationEvent $event)
{
if ($event->isTableExist(CreateMigrationTableMigration::MIGRATION_TABLE)) {
$data = $event->getData(sprintf('select * from %s where id in (select max(id) from %s group by bundle)', CreateMigrationTableMigration::MIGRATION_TABLE, CreateMigrationTableMigration::MIGRATION_TABLE));
foreach ($data as $val) {
$event->setLoadedVersion($val['bundle'], $val['version']);
}
} else {
$event->addMigration(new CreateMigrationTableMigration());
// load MigrationTable initial data for BAP and OroCRM bundles installed before migrations is introduced
// @todo: this transient solution can be removed in a future
// when we ensure RC1 and RC2 are updated for all clients
if ($event->isTableExist('oro_installer_bundle_version')) {
$oroTableDataConfig = $this->kernel->locateResource('@OroMigrationBundle/EventListener/MigrationTableData/Oro.yml');
$bundleVersions = Yaml::parse(realpath($oroTableDataConfig));
$oroCrmTableDataConfig = $this->kernel->locateResource('@OroMigrationBundle/EventListener/MigrationTableData/OroCRM.yml');
if ($event->isTableExist('orocrm_account')) {
$bundleVersions = array_merge($bundleVersions, Yaml::parse(realpath($oroCrmTableDataConfig)));
}
foreach ($bundleVersions as $bundleName => $version) {
$event->setLoadedVersion($bundleName, $version);
}
$event->addMigration(new UpdateBundleVersionMigration($bundleVersions));
$event->addMigration(new UpdateEntityConfigMigration());
}
}
}
示例4: importUnits
/**
* Imports units.
*
* @return array An array with the keys "skipped" and "imported" which contain the number of units skipped and imported
* @throws \Exception If an error occured
*/
public function importUnits()
{
$path = $this->kernel->locateResource(self::UNIT_PATH . self::UNIT_DATA);
$yaml = new Parser();
$data = $yaml->parse(file_get_contents($path));
$count = 0;
$skipped = 0;
foreach ($data as $unitName => $unitData) {
$unit = $this->getUnit($unitName);
if ($unit === null) {
$unit = new Unit();
$unit->setName($unitName);
$unit->setSymbol($unitData["symbol"]);
if (array_key_exists("prefixes", $unitData)) {
if (!is_array($unitData["prefixes"])) {
throw new \Exception($unitName . " doesn't contain a prefix list, or the prefix list is not an array.");
}
foreach ($unitData["prefixes"] as $name) {
$prefix = $this->getSiPrefix($name);
if ($prefix === null) {
throw new \Exception("Unable to find SI Prefix " . $name);
}
$unit->getPrefixes()->add($prefix);
}
}
$this->entityManager->persist($unit);
$this->entityManager->flush();
$count++;
} else {
$skipped++;
}
}
return array("imported" => $count, "skipped" => $skipped);
}
示例5: getConfigurations
/**
* @return array
*/
public function getConfigurations()
{
if ($this->configuration !== null) {
return $this->configuration;
}
$bundles = $this->kernel->getBundles();
$configuration = [];
foreach ($bundles as $bundle) {
try {
$class = get_class($bundle);
$classParts = explode('\\', $class);
$bundleName = array_pop($classParts);
$file = $this->kernel->locateResource(sprintf('@%s/Resources/config/search.yml', $bundleName));
} catch (\Exception $e) {
continue;
}
$data = $this->parseFile($file);
if (is_array($data)) {
foreach ($data as $class => $config) {
$configuration[$class] = $config;
}
}
}
$this->configuration = $configuration;
return $configuration;
}
示例6: setFilename
/**
* @param string $filename
* @throws \InvalidArgumentException
*/
public function setFilename($filename)
{
if ($filename && $filename[0] == '@') {
$filename = $this->kernel->locateResource($filename);
}
if (!is_file($filename)) {
throw new \InvalidArgumentException('Specified file does not exist: ' . $filename);
}
$this->filename = $filename;
}
示例7: getPrivateKey
/**
* @return \XMLSecurityKey
*/
public function getPrivateKey()
{
if (!$this->_key) {
$filename = $this->keyFile;
if ($filename[0] == '@') {
$filename = $this->kernel->locateResource($filename);
}
$this->_key = KeyHelper::createPrivateKey($filename, $this->keyPass, true, false);
}
return $this->_key;
}
示例8: formatTranslationConfig
/**
* Format the string config to array config with "file" attribute and translations.
*
* @param string|array $config The config
* @param KernelInterface $kernel The kernel
*
* @return array
*/
public static function formatTranslationConfig($config, KernelInterface $kernel)
{
$config = static::formatConfig($config);
$config['file'] = $kernel->locateResource($config['file']);
if (isset($config['translations']) && is_array($config['translations'])) {
/* @var array $translation */
foreach ($config['translations'] as &$translation) {
$translation['file'] = $kernel->locateResource($translation['file']);
}
}
return $config;
}
示例9: loadFixtureFiles
/**
* Gets all fixtures files
*/
protected function loadFixtureFiles()
{
foreach ($this->bundles as $bundle) {
$file = '*';
if (strpos($bundle, '/')) {
list($bundle, $file) = explode('/', $bundle);
}
$path = $this->kernel->locateResource('@' . $bundle);
$files = glob($path . $this->directory . '/' . $file . '.yml');
$this->fixture_files = array_unique(array_merge($this->fixture_files, $files));
}
}
示例10: getRawData
/**
* @param $name
*
* @return array
* @throws \Exception
*/
private function getRawData($name)
{
if (isset($this->presets[$name])) {
return $this->presets[$name];
}
if (false === strpos($name, ':')) {
throw new \Exception(sprintf('Malformed namespaced configuration name "%s" (expecting "namespace:pagename").', $name));
}
list($namespace, $name) = explode(':', $name, 2);
$path = $this->kernel->locateResource('@' . $namespace . '/Resources/config/pagetemplates/' . $name . '.yml');
$rawData = Yaml::parse(file_get_contents($path));
return $rawData;
}
示例11: createManufacturer
protected function createManufacturer($manufacturerName, $manufacturerData)
{
$manufacturer = new Manufacturer();
$manufacturer->setName($manufacturerName);
if (array_key_exists('iclogos', $manufacturerData)) {
foreach ($manufacturerData['iclogos'] as $icLogo) {
$manufacturerIcLogo = new ManufacturerICLogo();
$file = $this->kernel->locateResource(self::MANUFACTURER_PATH . $icLogo);
$this->uploadedFileService->replaceFromFilesystem($manufacturerIcLogo, new File($file));
$manufacturer->addIcLogo($manufacturerIcLogo);
}
}
$this->entityManager->persist($manufacturer);
}
示例12: let
/**
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container_stub
* @param \Symfony\Component\HttpKernel\KernelInterface $kernel_stub
*/
function let($container_stub, $kernel_stub)
{
$template_path = realpath(__DIR__ . '/../../../../Action/Template/');
$kernel_stub->locateResource(Argument::any())->willReturn($template_path);
$container_stub->get(Argument::any())->willReturn($kernel_stub);
$this->setContainer($container_stub);
}
示例13: getOriginCover
/**
* @param Item $item
*
* @return string
*/
protected function getOriginCover(Item $item)
{
if (!$this->origin_dir) {
$this->origin_dir = $this->kernel->locateResource('@AnimeDbCatalogBundle/Resources/private/images/');
}
return $this->origin_dir . $item->getItem()->getCover();
}
示例14: __construct
public function __construct(SecureRandomInterface $rng, KernelInterface $kernel, array $languages)
{
parent::__construct($rng);
$this->resource = $kernel->locateResource('@TweedeGolfGeneratorBundle/Resources/wordlists');
$this->setLanguages($languages);
$this->setSeparator(' ');
}
示例15: __construct
public function __construct(EntityManagerInterface $em, KernelInterface $kernel, ContainerInterface $container, VersionAccessor $versionAccessor, $migrationConfigPath)
{
$this->em = $em;
$this->migrations = Yaml::parse($kernel->locateResource($migrationConfigPath));
$this->container = $container;
$this->versionAccessor = $versionAccessor;
}