本文整理汇总了PHP中Webmozart\Assert\Assert::isInstanceOf方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::isInstanceOf方法的具体用法?PHP Assert::isInstanceOf怎么用?PHP Assert::isInstanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::isInstanceOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCheckoutComplete
/**
* {@inheritdoc}
*/
public function onCheckoutComplete(GenericEvent $event)
{
/** @var OrderInterface $order */
$order = $event->getSubject();
Assert::isInstanceOf($order, OrderInterface::class);
$this->session->set('sylius_order_id', $order->getId());
}
示例2: preSetData
/**
* @param FormEvent $event
*/
public function preSetData(FormEvent $event)
{
/** @var ProductInterface $product */
$product = $event->getData();
Assert::isInstanceOf($product, ProductInterface::class);
$this->generator->generate($product);
}
示例3: supports
/**
* {@inheritdoc}
*/
public function supports(OrderInterface $order, ZoneInterface $zone)
{
$channel = $order->getChannel();
/** @var ChannelInterface $channel */
Assert::isInstanceOf($channel, ChannelInterface::class);
return $channel->getTaxCalculationStrategy() === $this->type;
}
示例4: uploadTaxonImage
/**
* @param GenericEvent $event
*/
public function uploadTaxonImage(GenericEvent $event)
{
$subject = $event->getSubject();
Assert::isInstanceOf($subject, TaxonInterface::class);
if ($subject->hasFile()) {
$this->uploader->upload($subject);
}
}
示例5: sendVerificationEmail
/**
* @param GenericEvent $event
*/
public function sendVerificationEmail(GenericEvent $event)
{
$customer = $event->getSubject();
Assert::isInstanceOf($customer, CustomerInterface::class);
$user = $customer->getUser();
Assert::notNull($user);
$this->handleUserVerificationToken($user);
}
示例6: selectElementFromAttributesDropdown
/**
* @param int $id
*/
private function selectElementFromAttributesDropdown($id)
{
/** @var Selenium2Driver $driver */
$driver = $this->getDriver();
Assert::isInstanceOf($driver, Selenium2Driver::class);
$driver->executeScript('$(\'[name="sylius_product_attribute_choice"]\').dropdown(\'show\');');
$driver->executeScript(sprintf('$(\'[name="sylius_product_attribute_choice"]\').dropdown(\'set selected\', %s);', $id));
}
示例7: transform
/**
* {@inheritdoc}
*/
public function transform($value)
{
if (null === $value) {
return null;
}
Assert::isInstanceOf($value, $this->repository->getClassName());
return PropertyAccess::createPropertyAccessor()->getValue($value, $this->identifier);
}
示例8: isEligible
/**
* {@inheritdoc}
*/
public function isEligible(PromotionSubjectInterface $subject, array $configuration)
{
Assert::isInstanceOf($subject, OrderInterface::class);
$channelCode = $subject->getChannel()->getCode();
if (!isset($configuration[$channelCode])) {
return false;
}
return $this->itemTotalRuleChecker->isEligible($subject, $configuration[$channelCode]);
}
示例9: process
/**
* {@inheritdoc}
*/
public function process(OrderInterface $order)
{
/** @var CoreOrderInterface $order */
Assert::isInstanceOf($order, CoreOrderInterface::class);
if (OrderInterface::STATE_CANCELLED === $order->getState()) {
return;
}
$this->exchangeRateUpdater->update($order);
}
示例10: render
/**
* {@inheritdoc}
*/
public function render(Field $field, $data, array $options)
{
$value = $this->dataExtractor->get($field, $data);
if (null === $value) {
return null;
}
Assert::isInstanceOf($value, \DateTime::class);
return $value->format($options['format']);
}
示例11: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (null === $value) {
return null;
}
$class = $this->repository->getClassName();
Assert::isInstanceOf($value, $class);
$accessor = PropertyAccess::createPropertyAccessor();
return $accessor->getValue($value, $this->identifier);
}
示例12: preSetData
/**
* @param FormEvent $event
*/
public function preSetData(FormEvent $event)
{
/** @var ProductInterface $product */
$product = $event->getData();
Assert::isInstanceOf($product, ProductInterface::class);
$form = $event->getForm();
/** Options should be disabled for configurable product if it has at least one defined variant */
$disableOptions = null !== $product->getFirstVariant() && false === $product->hasVariants();
$form->add('options', 'sylius_product_option_choice', ['required' => false, 'disabled' => $disableOptions, 'multiple' => true, 'label' => 'sylius.form.product.options']);
}
示例13: deleteUser
/**
* @param GenericEvent $event
*
* @throws \InvalidArgumentException
*/
public function deleteUser(GenericEvent $event)
{
$user = $event->getSubject();
Assert::isInstanceOf($user, UserInterface::class);
$token = $this->tokenStorage->getToken();
if (null !== $token && ($loggedUser = $token->getUser()) && $loggedUser->getId() === $user->getId()) {
$event->stopPropagation();
$this->session->getBag('flashes')->add('error', 'Cannot remove currently logged in user.');
}
}
示例14: preSetData
/**
* @param FormEvent $event
*/
public function preSetData(FormEvent $event)
{
/** @var ProductInterface $product */
$product = $event->getData();
Assert::isInstanceOf($product, ProductInterface::class);
if ($product->isSimple()) {
$form = $event->getForm();
$form->add('variant', 'sylius_product_variant', ['property_path' => 'variants[0]']);
$form->remove('options');
}
}
示例15: preSetData
/**
* @param FormEvent $event
*/
public function preSetData(FormEvent $event)
{
$form = $event->getForm();
/** @var ReviewInterface $review */
$review = $event->getData();
$author = $form->getConfig()->getOption('author');
Assert::isInstanceOf($review, ReviewInterface::class);
if (null === $author && null === $review->getAuthor()) {
$form->add('author', 'sylius_customer_guest');
}
}