has() 공개 메소드

Returns true if a parameter name is defined.
public has ( string $name ) : boolean
$name string The parameter name
리턴 boolean true if the parameter name is defined, false otherwise
예제 #1
0
 /**
  * @covers Symfony\Component\DependencyInjection\ParameterBag\ParameterBag::has
  */
 public function testHas()
 {
     $bag = new ParameterBag(array('foo' => 'bar'));
     $this->assertTrue($bag->has('foo'), '->has() returns true if a parameter is defined');
     $this->assertTrue($bag->has('Foo'), '->has() converts the key to lowercase');
     $this->assertFalse($bag->has('bar'), '->has() returns false if a parameter is not defined');
 }
    /**
     * {@inheritdoc}
     */
    public function filterDump(AssetInterface $asset)
    {
        if (preg_match('/\\.yfp\\.js$/', $asset->getSourcePath())) {
            $content = $asset->getContent();
            preg_match('/(\\w+)\\.yfp\\.js$/', $asset->getSourcePath(), $matches);
            if (isset($matches[1])) {
                $name = $matches[1];
                $pluginName = str_replace(' ', '', ucwords(strtr($matches[1], '_-', '  ')));
                $config = [];
                if ($this->parameterBag->has("ynlo.js_plugin.{$name}")) {
                    $config = $this->parameterBag->get("ynlo.js_plugin.{$name}");
                }
                $jsonConfig = json_encode($config, JSON_FORCE_OBJECT);
                $autoRegister = null;
                if (strpos($content, "YnloFramework.register('{$pluginName}')") === false && strpos($content, "YnloFramework.register(\"{$pluginName}\\')") === false) {
                    $autoRegister = "\nYnloFramework.register('{$pluginName}');";
                }
                $settings = <<<JAVASCRIPT
{$autoRegister}
YnloFramework.{$pluginName}.config = \$.extend({}, YnloFramework.{$pluginName}.config, {$jsonConfig});

JAVASCRIPT;
                $asset->setContent($content . $settings);
            }
        }
    }
예제 #3
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param \Symfony\Component\HttpFoundation\Session\Session $session
  * @param \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $requestQuery
  */
 function it_redirects_to_passed_redirect_uri($request, $session, $requestQuery)
 {
     $request->getSession()->willReturn($session);
     $request->query = $requestQuery;
     $requestQuery->has('redirect_uri')->willReturn(true);
     $requestQuery->get('redirect_uri')->willReturn('uri_to_redirect_to');
     $response = $this->localeAction('qw', $request);
     $response->getTargetUrl()->shouldReturn('uri_to_redirect_to');
 }
 /**
  * Attempt to get an attribute from the assertion.
  *
  * @param string $name
  * @param null   $default
  * @return mixed|null
  */
 public function getAttribute($name, $default = null)
 {
     $attributeDefinition = $this->attributeDictionary->getAttributeDefinition($name);
     // try first by urn:mace, then by urn:oid
     if ($this->assertionAttributes->has($attributeDefinition->getUrnMace())) {
         $attribute = $this->assertionAttributes->get($attributeDefinition->getUrnMace());
     } elseif ($this->assertionAttributes->has($attributeDefinition->getUrnOid())) {
         $attribute = $this->assertionAttributes->get($attributeDefinition->getUrnOid());
     } else {
         return $default;
     }
     // if it is singular, it should return the single value if it has a value
     if ($attributeDefinition->getMultiplicity() === AttributeDefinition::MULTIPLICITY_SINGLE) {
         $count = count($attribute);
         if ($count > 1) {
             throw new UnexpectedValueException(sprintf('AttributeDefinition "%s" has a single-value multiplicity, yet returned' . ' "%d" values', $attributeDefinition->getName(), count($attribute)));
         } elseif ($count === 0) {
             $attribute = null;
         } else {
             $attribute = reset($attribute);
         }
     }
     return $attribute;
 }
예제 #5
0
 /**
  * Checks if current formatter has parameter.
  *
  * @param string $name
  *
  * @return Boolean
  */
 public final function hasParameter($name)
 {
     return $this->parameters->has($name);
 }
 /**
  * {@inheritDoc}
  */
 public function has($name)
 {
     return isset($GLOBALS['conf']) && array_key_exists($name, $GLOBALS['conf']) || parent::has($name);
 }
예제 #7
0
 public function getParameter($name, $default = null)
 {
     return $this->parameters->has($name) ? $this->parameters->get($name) : $default;
 }