本文整理汇总了PHP中Assert\Assertion::implementsInterface方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::implementsInterface方法的具体用法?PHP Assertion::implementsInterface怎么用?PHP Assertion::implementsInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::implementsInterface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setValue
/**
* @param mixed $value
*/
protected function setValue($value)
{
//We use the string assertion first
parent::setValue($value);
//and then check, if we really got an item class
Assertion::implementsInterface($value, 'Prooph\\Processing\\Type\\Type');
}
示例2: create
public function create($data)
{
if (!array_key_exists("collect_data_trigger", $data)) {
return new ApiProblemResponse(new ApiProblem(422, 'Root key collect_data_trigger missing in request data'));
}
$data = $data["collect_data_trigger"];
if (!array_key_exists('processing_type', $data)) {
return new ApiProblemResponse(new ApiProblem(422, 'Key processing_type is missing'));
}
$processingType = $data['processing_type'];
if (!class_exists($processingType)) {
return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is unknown'));
}
try {
Assertion::implementsInterface($processingType, 'Prooph\\Processing\\Type\\Type');
} catch (\InvalidArgumentException $ex) {
return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is not valid'));
}
$wfMessage = WorkflowMessage::collectDataOf($processingType::prototype(), __CLASS__, $this->ProcessingConfig->getNodeName());
$this->messageLogger->logIncomingMessage($wfMessage);
$this->workflowEngine->dispatch($wfMessage);
/** @var $response Response */
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Location', $this->url()->fromRoute('prooph.link/processor_proxy/api/messages', ['id' => $wfMessage->uuid()->toString()]));
$response->setStatusCode(201);
return $response;
}
示例3: __construct
/**
* Create a new value object
* @param array $value
*/
public function __construct($value)
{
Assertion::isArray($value);
foreach ($value as $object) {
Assertion::implementsInterface($object, EventInterface::class);
}
$this->value = SplFixedArray::fromArray($value);
}
示例4: createContainer
private function createContainer()
{
$container = new ContainerBuilder();
// retrieve security class
$values = \Parameters::get('security');
$class = $values['security']['classes'];
$session_name = $values['session']['name'];
// test if class exist and implement interface
try {
Assertion::ClassExists($class);
Assertion::implementsInterface($class, '\\GL\\Core\\Security\\AuthenticationServiceInterface');
} catch (AssertionFailedException $e) {
echo $e->getMessage();
die;
}
// Inject mailer
$container->register('mailer', 'GL\\Core\\Tools\\Mailer');
// Inject Request
$container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setFactory("Symfony\\Component\\HttpFoundation\\Request::createFromGlobals");
// Inject Request helper
$container->register('request_helper', 'GL\\Core\\Helpers\\RequestHelper')->addMethodCall('setRequest', array(new Reference('request')));
// Inject Twig Service
$container->register('template', 'GL\\Core\\Templating\\TemplateProvider');
// Inject RouteCollection
$container->register('routes', 'Symfony\\Component\\Routing\\RouteCollection')->setFactory("GL\\Core\\Routing\\RouteProvider::GetRouteCollection");
if (class_exists("\\PHPExcel")) {
// Inject PHPExcel Wrapper
$container->register('excel', 'GL\\Core\\Tools\\Excel');
}
if (class_exists("\\TCPDF")) {
// Inject FPDF Wrapper
$container->register('pdf', 'GL\\Core\\Tools\\PDF');
}
// Inject Session
$container->register('session', 'Symfony\\Component\\HttpFoundation\\Session\\Session')->addMethodCall('setName', array($session_name))->addMethodCall('start');
// Inject Crsf verifier
$container->register('crsf', 'GL\\Core\\Security\\FormCrsf')->addArgument(new Reference('session'))->addArgument(new Reference('request'));
// Inject translator service
$container->register('translator', 'GL\\Core\\Config\\Translator');
// Inject Security Service
$container->register('security', $class)->addArgument(new Reference('session'))->addArgument(new Reference('request'))->addMethodCall('autologin');
// Inject DebugBar
$container->register('debug', 'GL\\Core\\Debug\\KLDebugBar');
// Inject Pdo Object
$container->register('pdo', 'PDO')->setFactory("GL\\Core\\Helpers\\DbHelper::getPdo");
// Inject Config
$container->register('config', 'GL\\Core\\Config\\Config');
// Inject DbHelper
$container->register('db', 'GL\\Core\\Helpers\\DbHelper');
// Inject Redis
$container->register('redis', 'GL\\Core\\Tools\\Redis');
// Inject services defined in config/services.yml
$loader = new YamlFileLoader($container, new FileLocator(SERVICEPATH));
$loader->load('services.yml');
$container->compile();
return $container;
}
示例5: __construct
/**
* @param string $relatedTypeClass
* @param Description $descriptionOfType
* @param PrototypeProperty[] $typeProperties
*/
public function __construct($relatedTypeClass, Description $descriptionOfType, array $typeProperties)
{
Assertion::implementsInterface($relatedTypeClass, 'Prooph\\Processing\\Type\\Type');
foreach ($typeProperties as $propertyOfType) {
Assertion::isInstanceOf($propertyOfType, 'Prooph\\Processing\\Type\\PrototypeProperty');
}
$this->relatedTypeClass = $relatedTypeClass;
$this->descriptionOfType = $descriptionOfType;
$this->typeProperties = $typeProperties;
PrototypeRegistry::registerPrototype($this);
}
示例6: withData
/**
* @param string $workflowId
* @param array $startMessage
* @param string $firstMessageHandlerId
* @return ScheduleFirstTasksForWorkflow
*/
public static function withData($workflowId, $startMessage, $firstMessageHandlerId)
{
Assertion::uuid($workflowId);
Assertion::uuid($firstMessageHandlerId);
Assertion::isArray($startMessage);
Assertion::keyExists($startMessage, 'message_type');
Assertion::keyExists($startMessage, 'processing_type');
$processingType = $startMessage['processing_type'];
Assertion::implementsInterface($processingType, Type::class);
return new self(__CLASS__, ['workflow_id' => $workflowId, 'start_message' => $startMessage, 'first_message_handler' => $firstMessageHandlerId]);
}
示例7: support
/**
* Supported processing types can be given as processing prototypes or a list of type classes
*
* @param Prototype[]|array $processingTypes
* @return ProcessingTypes
*/
public static function support(array $processingTypes)
{
$prototypes = [];
foreach ($processingTypes as $typeClassOrPrototype) {
if ($typeClassOrPrototype instanceof Prototype) {
$prototypes[] = $typeClassOrPrototype;
} else {
Assertion::string($typeClassOrPrototype);
Assertion::classExists($typeClassOrPrototype);
Assertion::implementsInterface($typeClassOrPrototype, Type::class);
$prototypes[] = $typeClassOrPrototype::prototype();
}
}
return new self($prototypes, false);
}
示例8: __construct
private function __construct($target, array $allowedTypes, $preferredType = null, array $metadata)
{
Assertion::notEmpty($target);
Assertion::string($target);
Assertion::notEmpty($allowedTypes);
$this->assertMetadata($metadata);
foreach ($allowedTypes as $allowedType) {
Assertion::classExists($allowedType);
Assertion::implementsInterface($allowedType, 'Prooph\\Processing\\Type\\Type');
}
if (!is_null($preferredType)) {
Assertion::inArray($preferredType, $allowedTypes);
}
$this->target = $target;
$this->allowedTypes = $allowedTypes;
$this->preferredType = $preferredType;
$this->metadata = $metadata;
}
示例9: withData
/**
* @param string $messageHandlerId
* @param string $name
* @param string $nodeName
* @param string $handlerType
* @param string $dataDirection
* @param array|string $supportedProcessingTypes
* @param array $processingMetadata
* @param string $metadataRiotTag
* @param string $icon
* @param string $iconType
* @param null|string $preferredProcessingType
* @param null|string $handlerProcessingId
* @param array $additionalData
* @return InstallMessageHandler
*/
public static function withData($messageHandlerId, $name, $nodeName, $handlerType, $dataDirection, $supportedProcessingTypes, array $processingMetadata, $metadataRiotTag, $icon, $iconType, $preferredProcessingType = null, $handlerProcessingId = null, array $additionalData = [])
{
Assertion::uuid($messageHandlerId);
Assertion::string($name);
Assertion::notEmpty($name);
Assertion::string($nodeName);
Assertion::notEmpty($nodeName);
Assertion::string($handlerType);
Assertion::string($dataDirection);
Assertion::string($metadataRiotTag);
Assertion::string($icon);
Assertion::string($iconType);
if (!is_null($preferredProcessingType)) {
Assertion::string($preferredProcessingType);
Assertion::implementsInterface($preferredProcessingType, Type::class);
}
if (!is_null($handlerProcessingId)) {
Assertion::string($handlerProcessingId);
}
if (!is_string($supportedProcessingTypes)) {
Assertion::isArray($supportedProcessingTypes);
}
return new self(__CLASS__, ['message_handler_id' => $messageHandlerId, 'name' => $name, 'node_name' => $nodeName, 'handler_type' => $handlerType, 'data_direction' => $dataDirection, 'supported_processing_types' => $supportedProcessingTypes, 'processing_metadata' => $processingMetadata, 'metadata_riot_tag' => $metadataRiotTag, 'icon' => $icon, 'icon_type' => $iconType, 'preferred_processing_type' => $preferredProcessingType, 'handler_processing_id' => $handlerProcessingId, 'additional_data' => $additionalData]);
}
示例10: testImplementsInterfaceWithClassObject
public function testImplementsInterfaceWithClassObject()
{
$class = new \ArrayObject();
Assertion::implementsInterface($class, '\\Traversable');
$this->setExpectedException('Assert\\AssertionFailedException', null, Assertion::INTERFACE_NOT_IMPLEMENTED);
Assertion::implementsInterface($class, '\\SplObserver');
}
示例11: collectDataFromMultipleFiles
private function collectDataFromMultipleFiles($fileNames, WorkflowMessage $workflowMessage, FileTypeAdapter $fileHandler)
{
$metadata = $workflowMessage->metadata();
$fileDataType = isset($metadata[self::META_FILE_DATA_TYPE]) ? $metadata[self::META_FILE_DATA_TYPE] : $workflowMessage->payload()->getTypeClass();
Assertion::implementsInterface($fileDataType, 'Prooph\\Processing\\Type\\Type');
$fileDataPrototype = $fileDataType::prototype();
$fileDataCollection = [];
$collectedData = null;
$typeClass = $workflowMessage->payload()->getTypeClass();
foreach ($fileNames as $filename) {
$fileDataCollection[] = $fileHandler->readDataForType($filename, $fileDataPrototype, $metadata);
}
if (isset($metadata[self::META_MERGE_FILES]) && $metadata[self::META_MERGE_FILES]) {
$mergedFileData = [];
foreach ($fileDataCollection as $fileData) {
if (!is_array($fileData)) {
$fileData = [$fileData];
}
$mergedFileData = ArrayUtils::merge($mergedFileData, $fileData);
}
$collectedData = $typeClass::fromNativeValue($mergedFileData);
} else {
if ($typeClass::prototype()->typeDescription()->nativeType() !== NativeType::COLLECTION) {
throw new \InvalidArgumentException(sprintf("Filename pattern %s matches multiple files but the requested processing type %s is not a collection.", $metadata['filename_pattern'], $typeClass));
}
$metadata[self::META_TOTAL_ITEMS] = count($fileDataCollection);
$collectedData = $typeClass::fromNativeValue($fileDataCollection);
}
return $workflowMessage->answerWith($collectedData, $metadata);
}
示例12: doctrineColumnToProcessingType
/**
* @param Column $column
* @return string
* @throws \RuntimeException
*/
private function doctrineColumnToProcessingType(Column $column)
{
if (!isset($this->doctrineProcessingTypeMap[$column->getType()->getName()])) {
throw new \RuntimeException(sprintf("No processing type mapping for doctrine type %s", $column->getType()->getName()));
}
$processingType = $this->doctrineProcessingTypeMap[$column->getType()->getName()];
if (!$column->getNotnull() || $column->getAutoincrement()) {
$processingType .= "OrNull";
if (!class_exists($processingType)) {
throw new \RuntimeException("Missing null type: for nullable column: " . $column->getName());
}
}
Assertion::implementsInterface($processingType, 'Prooph\\Processing\\Type\\Type');
return $processingType;
}
示例13: run
private function run($instance, $type = "up")
{
// test if class exist and implement interface
try {
$class = get_class($instance);
Assertion::ClassExists($class);
Assertion::implementsInterface($class, '\\GL\\Core\\Migration\\MigrationInterface');
$max = 0;
// get all migrations in db
$migrations = MigrationModel::all();
// find max batch id version
if (count($migrations) > 0) {
$max = $migrations->max('db_version');
}
$batchid = $max + 1;
// retrieve className
$id = $instance->getUniqueTag();
// find if this instance was not executed
$exec = MigrationModel::where('migration', '=', $id)->first();
$bExec = true;
if ($exec != null) {
if ($exec->status == $type) {
// always executed
$bExec = false;
}
}
if ($bExec) {
$instance->{$type}();
// insert in db
if ($exec == null) {
$exec = new MigrationModel();
}
$exec->class = $class;
$exec->migration = $id;
$exec->status = $type;
$exec->db_version = $batchid;
$exec->save();
}
} catch (\Exception $ex) {
echo $ex;
} catch (AssertionFailedException $e) {
echo $e;
}
}
示例14: executeBefores
/**
* Function execute before action execute
* @param string $route actual route
* @return boolean
*/
public function executeBefores($route)
{
$ret = false;
$fnArray = \Functions::getAll();
if (isset($fnArray)) {
foreach ($fnArray as $key => $value) {
if ($value["type"] == "before") {
// for each global function defined
$arrRoutes = isset($value["routes"]) ? $value["routes"] : null;
$scope = isset($value["scope"]) ? $value["scope"] : "all";
$class = $value["class"];
// test if class exist and implements interface
Assertion::ClassExists($class);
Assertion::implementsInterface($class, '\\GL\\Core\\Controller\\BeforeFunctionInterface');
$bExecute = $this->IsAllowed($arrRoutes, $route, $scope);
if ($bExecute) {
$exc = new $class($this->_container);
$ret = $exc->execute();
}
}
}
}
return $ret;
}
示例15: changeTypeClass
/**
* @param string $newTypeClass
*/
public function changeTypeClass($newTypeClass)
{
Assertion::string($newTypeClass);
Assertion::implementsInterface($newTypeClass, 'Prooph\\Processing\\Type\\Type');
$this->typeClass = $newTypeClass;
if (is_null($this->data) && !is_null($this->type)) {
$this->data = $this->extractTypeData();
}
$this->type = null;
}