getArgument() 공개 메소드

Returns an argument specified by name
public getArgument ( string $argumentName ) : Argument
$argumentName string Name of the argument to retrieve
리턴 Argument
 /**
  * @test
  */
 public function getArgumentWithNonExistingArgumentNameThrowsException()
 {
     $arguments = new Arguments();
     try {
         $arguments->getArgument('someArgument');
         $this->fail('getArgument() did not throw an exception although the specified argument does not exist.');
     } catch (NoSuchArgumentException $exception) {
         $this->assertTrue(true);
     }
 }
 /**
  * Initialize the property mapping configuration in $controllerArguments if
  * the trusted properties are set inside the request.
  *
  * @param ActionRequest $request
  * @param Arguments $controllerArguments
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(ActionRequest $request, Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }
 /**
  * Helper which initializes the property mapping configuration and returns arguments
  *
  * @param array $trustedProperties
  * @return Mvc\Controller\Arguments
  */
 protected function initializePropertyMappingConfiguration(array $trustedProperties)
 {
     $request = $this->getMockBuilder(Mvc\ActionRequest::class)->setMethods(['getInternalArgument'])->disableOriginalConstructor()->getMock();
     $request->expects($this->any())->method('getInternalArgument')->with('__trustedProperties')->will($this->returnValue('fooTrustedProperties'));
     $arguments = new Mvc\Controller\Arguments();
     $mockHashService = $this->getMockBuilder(HashService::class)->setMethods(['validateAndStripHmac'])->getMock();
     $mockHashService->expects($this->once())->method('validateAndStripHmac')->with('fooTrustedProperties')->will($this->returnValue(serialize($trustedProperties)));
     $arguments->addNewArgument('foo', 'something');
     $this->inject($arguments->getArgument('foo'), 'propertyMappingConfiguration', new PropertyMappingConfiguration());
     $requestHashService = new Mvc\Controller\MvcPropertyMappingConfigurationService();
     $this->inject($requestHashService, 'hashService', $mockHashService);
     $requestHashService->initializePropertyMappingConfigurationFromRequest($request, $arguments);
     return $arguments;
 }