本文整理汇总了PHP中Sylius\Component\Resource\Factory\FactoryInterface::createNew方法的典型用法代码示例。如果您正苦于以下问题:PHP FactoryInterface::createNew方法的具体用法?PHP FactoryInterface::createNew怎么用?PHP FactoryInterface::createNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Resource\Factory\FactoryInterface
的用法示例。
在下文中一共展示了FactoryInterface::createNew方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createWithVariant
/**
* {@inheritdoc}
*/
public function createWithVariant()
{
$variant = $this->variantFactory->createNew();
$product = $this->factory->createNew();
$product->addVariant($variant);
return $product;
}
示例2: createWithCustomer
/**
* {@inheritdoc}
*/
public function createWithCustomer(CustomerInterface $customer)
{
/** @var AddressInterface $address*/
$address = $this->decoratedFactory->createNew();
$address->setCustomer($customer);
return $address;
}
示例3: createNew
/**
* {@inheritdoc}
*/
public function createNew()
{
/** @var StaticContent $staticContent */
$staticContent = $this->decoratedFactory->createNew();
$staticContent->setParentDocument($this->documentManager->find(null, $this->staticContentParentPath));
return $staticContent;
}
示例4: generate
/**
* {@inheritdoc}
*/
public function generate(VariableInterface $variable)
{
if (!$variable->hasOptions()) {
throw new \InvalidArgumentException('Cannot generate variants for an object without options.');
}
$optionSet = array();
$optionMap = array();
foreach ($variable->getOptions() as $k => $option) {
foreach ($option->getValues() as $value) {
$optionSet[$k][] = $value->getId();
$optionMap[$value->getId()] = $value;
}
}
$permutations = $this->setBuilder->build($optionSet);
foreach ($permutations as $permutation) {
$variant = $this->variantFactory->createNew();
$variant->setObject($variable);
$variant->setDefaults($variable->getMasterVariant());
if (is_array($permutation)) {
foreach ($permutation as $id) {
$variant->addOption($optionMap[$id]);
}
} else {
$variant->addOption($optionMap[$permutation]);
}
$variable->addVariant($variant);
$this->process($variable, $variant);
}
}
示例5: createNew
/**
* {@inheritdoc}
*/
public function createNew()
{
/** @var Route $route */
$route = $this->decoratedFactory->createNew();
$route->setParentDocument($this->documentManager->find(null, $this->routeParentPath));
return $route;
}
示例6: load
/**
* {@inheritdoc}
*/
public function load($schemaAlias, $namespace = null, $ignoreUnknown = true)
{
/** @var SchemaInterface $schema */
$schema = $this->schemaRegistry->get($schemaAlias);
/** @var SettingsResolverInterface $resolver */
$resolver = $this->resolverRegistry->get($schemaAlias);
// try to resolve settings for schema alias and namespace
$settings = $resolver->resolve($schemaAlias, $namespace);
if (!$settings) {
$settings = $this->settingsFactory->createNew();
$settings->setSchemaAlias($schemaAlias);
}
// We need to get a plain parameters array since we use the options resolver on it
$parameters = $settings->getParameters();
$settingsBuilder = new SettingsBuilder();
$schema->buildSettings($settingsBuilder);
// Remove unknown settings' parameters (e.g. From a previous version of the settings schema)
if (true === $ignoreUnknown) {
foreach ($parameters as $name => $value) {
if (!$settingsBuilder->isDefined($name)) {
unset($parameters[$name]);
}
}
}
$parameters = $settingsBuilder->resolve($parameters);
$settings->setParameters($parameters);
return $settings;
}
示例7: createForPromotion
/**
* {@inheritdoc}
*/
public function createForPromotion(PromotionInterface $promotion)
{
Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
$coupon = $this->factory->createNew();
$coupon->setPromotion($promotion);
return $coupon;
}
示例8: theStoreHasDisabledLocale
/**
* @Given the store has disabled locale :localeCode
*/
public function theStoreHasDisabledLocale($localeCode)
{
$locale = $this->localeFactory->createNew();
$locale->setCode($localeCode);
$locale->disable();
$this->saveLocale($locale);
}
示例9: createTaxon
/**
* @param string $name
*
* @return TaxonInterface
*/
private function createTaxon($name)
{
$taxon = $this->taxonFactory->createNew();
$taxon->setName($name);
$taxon->setCode($this->getCodeFromName($name));
return $taxon;
}
示例10: createNew
/**
* {@inheritdoc}
*/
public function createNew()
{
$taxon = $this->taxonFactory->createNew();
$taxonomy = $this->translatableFactory->createNew();
$taxonomy->setRoot($taxon);
return $taxonomy;
}
示例11: create
/**
* {@inheritdoc}
*/
public function create(array $options = [])
{
$options = $this->optionsResolver->resolve($options);
/** @var PromotionInterface $promotion */
$promotion = $this->promotionFactory->createNew();
$promotion->setCode($options['code']);
$promotion->setName($options['name']);
$promotion->setDescription($options['description']);
$promotion->setCouponBased($options['coupon_based']);
$promotion->setUsageLimit($options['usage_limit']);
$promotion->setExclusive($options['exclusive']);
$promotion->setPriority($options['priority']);
if (isset($options['starts_at'])) {
$promotion->setStartsAt(new \DateTime($options['starts_at']));
}
if (isset($options['ends_at'])) {
$promotion->setEndsAt(new \DateTime($options['ends_at']));
}
foreach ($options['channels'] as $channel) {
$promotion->addChannel($channel);
}
foreach ($options['rules'] as $rule) {
/** @var PromotionRuleInterface $promotionRule */
$promotionRule = $this->promotionRuleExampleFactory->create($rule);
$promotion->addRule($promotionRule);
}
foreach ($options['actions'] as $action) {
/** @var PromotionActionInterface $promotionAction */
$promotionAction = $this->promotionActionExampleFactory->create($action);
$promotion->addAction($promotionAction);
}
return $promotion;
}
示例12: createCountryNamed
/**
* @param string $name
*/
private function createCountryNamed($name)
{
/** @var CountryInterface $country */
$country = $this->countryFactory->createNew();
$country->setCode($this->countryNameConverter->convertToCode($name));
$this->countryRepository->add($country);
}
示例13: createCountryNamed
/**
* @param string $name
*/
private function createCountryNamed($name)
{
/** @var CountryInterface $country */
$country = $this->countryFactory->createNew();
$country->setCode($this->getCountryCodeByEnglishCountryName($name));
$this->countryRepository->add($country);
}
示例14: getItemFormView
/**
* @param array $options
*
* @return FormView
*/
public function getItemFormView(array $options = array())
{
$cartItem = $this->cartItemFactory->createNew();
$this->orderItemQuantityModifier->modify($cartItem, 1);
$form = $this->formFactory->create('sylius_cart_item', $cartItem, $options);
return $form->createView();
}
示例15: createCustomerGroup
/**
* @param string $name
*/
private function createCustomerGroup($name)
{
/** @var CustomerGroupInterface $customerGroup */
$customerGroup = $this->customerGroupFactory->createNew();
$customerGroup->setName(ucfirst($name));
$this->sharedStorage->set('customer_group', $customerGroup);
$this->customerGroupRepository->add($customerGroup);
}