本文整理汇总了PHP中Thelia\Model\ConfigQuery::create方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery::create方法的具体用法?PHP ConfigQuery::create怎么用?PHP ConfigQuery::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thelia\Model\ConfigQuery
的用法示例。
在下文中一共展示了ConfigQuery::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_status
public function update_status(OrderEvent $event)
{
if ($event->getOrder()->getDeliveryModuleId() === LocalPickup::getModCode()) {
if ($event->getOrder()->isSent()) {
$contact_email = ConfigQuery::read('store_email');
if ($contact_email) {
$message = MessageQuery::create()->filterByName('order_confirmation_localpickup')->findOne();
if (false === $message) {
throw new \Exception("Failed to load message 'order_confirmation_localpickup'.");
}
$order = $event->getOrder();
$customer = $order->getCustomer();
$store = ConfigQuery::create();
$country = CountryQuery::create()->findPk($store->read("store_country"));
$country = CountryI18nQuery::create()->filterById($country->getId())->findOneByLocale($order->getLang()->getLocale())->getTitle();
$this->parser->assign('order_id', $order->getId());
$this->parser->assign('order_ref', $order->getRef());
$this->parser->assign('store_name', $store->read("store_name"));
$this->parser->assign('store_address1', $store->read("store_address1"));
$this->parser->assign('store_address2', $store->read("store_address2"));
$this->parser->assign('store_address3', $store->read("store_address3"));
$this->parser->assign('store_zipcode', $store->read("store_zipcode"));
$this->parser->assign('store_city', $store->read("store_city"));
$this->parser->assign('store_country', $country);
$message->setLocale($order->getLang()->getLocale());
$instance = \Swift_Message::newInstance()->addTo($customer->getEmail(), $customer->getFirstname() . " " . $customer->getLastname())->addFrom($contact_email, ConfigQuery::read('store_name'));
// Build subject and body
$message->buildMessage($this->parser, $instance);
$this->getMailer()->send($instance);
}
}
}
}
示例2: checkDuplicateName
public function checkDuplicateName($value, ExecutionContextInterface $context)
{
$config = ConfigQuery::create()->findOneByName($value);
if ($config) {
$context->addViolation(Translator::getInstance()->trans('A variable with name "%name" already exists.', array('%name' => $value)));
}
}
示例3: getExistingObject
protected function getExistingObject()
{
$config = ConfigQuery::create()->findOneById($this->getRequest()->get('variable_id'));
if (null !== $config) {
$config->setLocale($this->getCurrentEditionLocale());
}
return $config;
}
示例4: __construct
public function __construct()
{
$configList = ConfigQuery::create()->filterByName(['payline_merchantId', 'payline_merchantAccesskey', 'payline_contractNumber', 'payline_env', 'payline_minimumAmount', 'payline_maximumAmount'])->find();
/** @var Config $config */
foreach ($configList as $config) {
$this->{str_replace('payline_', '', $config->getName())} = $config->getValue();
}
}
示例5: delete
/**
* Delete a configuration entry
*
* @param \Thelia\Core\Event\Config\ConfigDeleteEvent $event
* @param $eventName
* @param EventDispatcherInterface $dispatcher
*/
public function delete(ConfigDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher)
{
if (null !== ($config = ConfigQuery::create()->findPk($event->getConfigId()))) {
if (!$config->getSecured()) {
$config->setDispatcher($dispatcher)->delete();
$event->setConfig($config);
}
}
}
示例6: buildModelCriteria
public function buildModelCriteria()
{
$id = $this->getId();
$name = $this->getVariable();
$secured = $this->getSecured();
$exclude = $this->getExclude();
$search = ConfigQuery::create();
$this->configureI18nProcessing($search);
if (!is_null($id)) {
$search->filterById($id);
}
if (!is_null($name)) {
$search->filterByName($name);
}
if (!is_null($exclude)) {
$search->filterById($exclude, Criteria::NOT_IN);
}
if ($this->getHidden() != BooleanOrBothType::ANY) {
$search->filterByHidden($this->getHidden() ? 1 : 0);
}
if (!is_null($secured) && $secured != BooleanOrBothType::ANY) {
$search->filterBySecured($secured ? 1 : 0);
}
$orders = $this->getOrder();
foreach ($orders as $order) {
switch ($order) {
case 'id':
$search->orderById(Criteria::ASC);
break;
case 'id_reverse':
$search->orderById(Criteria::DESC);
break;
case 'name':
$search->orderByName(Criteria::ASC);
break;
case 'name_reverse':
$search->orderByName(Criteria::DESC);
break;
case 'title':
$search->addAscendingOrderByColumn('i18n_TITLE');
break;
case 'title_reverse':
$search->addDescendingOrderByColumn('i18n_TITLE');
break;
case 'value':
$search->orderByValue(Criteria::ASC);
break;
case 'value_reverse':
$search->orderByValue(Criteria::DESC);
break;
}
}
return $search;
}
示例7: update
public function update($currentVersion, $newVersion, ConnectionInterface $con = null)
{
// Migrate old configuration
if (null === self::getConfigValue('atos_merchantId', null)) {
if (null !== ($atosConfigs = ConfigQuery::create()->filterByName('atos_%', Criteria::LIKE)->find())) {
/** @var Config $atosConfig */
foreach ($atosConfigs as $atosConfig) {
Atos::setConfigValue($atosConfig->getName(), $atosConfig->getValue());
$atosConfig->delete($con);
}
}
}
parent::update($currentVersion, $newVersion, $con);
}
示例8: testFormatSimpleQueryWithAliases
public function testFormatSimpleQueryWithAliases()
{
/**
* Aliases must not be case sensitive
*/
$aliases = ["coNfiG.iD" => "id", "conFig.NaMe" => "name", "CoNfIg.Value" => "value", "config.hidden" => "hidden", "ConFig.Secured" => "secured"];
$formatterData = new FormatterData($aliases);
$query = ConfigQuery::create()->limit(1);
$formattedData = $formatterData->loadModelCriteria($query)->getData();
/** @var \Thelia\Model\Config $result */
$result = $query->findOne();
$formattedResult = [["id" => $result->getId(), "name" => $result->getName(), "value" => $result->getValue(), "config.created_at" => $result->getCreatedAt(), "config.updated_at" => $result->getUpdatedAt(), "hidden" => $result->getHidden(), "secured" => $result->getHidden()]];
$this->assertEquals($formattedResult, $formattedData);
}
示例9: createPopInImageFolder
/**
* Create and save the id of the pop-in images folder if necessary.
*
* @throws \Exception
* @throws PropelException
*/
protected function createPopInImageFolder()
{
$imageFolderIdConfig = ConfigQuery::create()->findOneByName(static::CONF_KEY_IMAGE_FOLDER_ID);
if (null !== $imageFolderIdConfig && null !== FolderQuery::create()->findPk($imageFolderIdConfig->getValue())) {
// we already have and know our images folder
return;
}
Propel::getConnection()->beginTransaction();
try {
// create the folder
$folder = new Folder();
$folder->setVisible(true);
/** @var Lang $lang */
foreach (LangQuery::create()->find() as $lang) {
$localizedTitle = Translator::getInstance()->trans("Pop-in images", [], static::MESSAGE_DOMAIN_BO, $lang->getLocale(), false);
if ($localizedTitle == "") {
continue;
}
$folder->setLocale($lang->getLocale())->setTitle($localizedTitle);
}
$folder->save();
// save the folder id in configuration
if ($folder->getId() !== null) {
$config = new Config();
$config->setName(static::CONF_KEY_IMAGE_FOLDER_ID)->setValue($folder->getId())->setHidden(false);
/** @var Lang $lang */
foreach (LangQuery::create()->find() as $lang) {
$localizedTitle = Translator::getInstance()->trans("Pop-in images folder id", [], static::MESSAGE_DOMAIN_BO, $lang->getLocale(), false);
if ($localizedTitle == "") {
continue;
}
$config->setLocale($lang->getLocale())->setTitle($localizedTitle);
}
$config->save();
}
} catch (\Exception $e) {
Propel::getConnection()->rollBack();
throw $e;
}
Propel::getConnection()->commit();
}
示例10: delete
/**
* Removes this object from datastore and sets delete attribute.
*
* @param ConnectionInterface $con
* @return void
* @throws PropelException
* @see Config::setDeleted()
* @see Config::isDeleted()
*/
public function delete(ConnectionInterface $con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($con === null) {
$con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
}
$con->beginTransaction();
try {
$deleteQuery = ChildConfigQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
$ret = $this->preDelete($con);
if ($ret) {
$deleteQuery->delete($con);
$this->postDelete($con);
$con->commit();
$this->setDeleted(true);
} else {
$con->commit();
}
} catch (Exception $e) {
$con->rollBack();
throw $e;
}
}
示例11: getConfig
/**
* Get the associated ChildConfig object
*
* @param ConnectionInterface $con Optional Connection object.
* @return ChildConfig The associated ChildConfig object.
* @throws PropelException
*/
public function getConfig(ConnectionInterface $con = null)
{
if ($this->aConfig === null && $this->id !== null) {
$this->aConfig = ChildConfigQuery::create()->findPk($this->id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aConfig->addConfigI18ns($this);
*/
}
return $this->aConfig;
}
示例12: deleteConfig
private function deleteConfig(InputInterface $input, OutputInterface $output)
{
$varName = $input->getArgument("name");
if (null === $varName) {
$output->writeln("<error>Need argument 'name' for get command</error>");
return;
}
$var = ConfigQuery::create()->findOneByName($varName);
if (null === $var) {
$output->writeln(sprintf("<error>Unknown variable '%s'</error>", $varName));
} else {
$var->delete();
$output->writeln(sprintf("<info>Variable '%s' has been deleted</info>", $varName));
}
}
示例13: unset
unset($query["admin_password_verif"]);
}
header(sprintf('location: config.php?%s', http_build_query($query)));
exit;
// Don't forget to exit, otherwise, the script will continue to run.
}
if ($_SESSION['install']['step'] == 5) {
// Check now if we can create the App.
$thelia = new \Thelia\Core\Thelia("install", true);
$thelia->boot();
$admin = new \Thelia\Model\Admin();
$admin->setLogin($_POST['admin_login'])->setPassword($_POST['admin_password'])->setFirstname('admin')->setLastname('admin')->setLocale(empty($_POST['admin_locale']) ? 'en_US' : $_POST['admin_locale'])->setLocale($_POST['admin_email'])->save();
\Thelia\Model\ConfigQuery::create()->filterByName('store_email')->update(array('Value' => $_POST['store_email']));
\Thelia\Model\ConfigQuery::create()->filterByName('store_notification_emails')->update(array('Value' => $_POST['store_email']));
\Thelia\Model\ConfigQuery::create()->filterByName('store_name')->update(array('Value' => $_POST['store_name']));
\Thelia\Model\ConfigQuery::create()->filterByName('url_site')->update(array('Value' => $_POST['url_site']));
$lang = \Thelia\Model\LangQuery::create()->findOneByLocale(empty($_POST['shop_locale']) ? "en_US" : $_POST['shop_locale']);
if (null !== $lang) {
$lang->toggleDefault();
}
$secret = \Thelia\Tools\TokenProvider::generateToken();
\Thelia\Model\ConfigQuery::write('form.secret', $secret, 0, 0);
}
//clean up cache directories
$fs = new \Symfony\Component\Filesystem\Filesystem();
$fs->remove(THELIA_ROOT . '/cache/prod');
$fs->remove(THELIA_ROOT . '/cache/dev');
$fs->remove(THELIA_ROOT . '/cache/install');
$request = \Thelia\Core\HttpFoundation\Request::createFromGlobals();
$_SESSION['install']['step'] = $step;
// Retrieve the website url
示例14: domainActivation
private function domainActivation($activate)
{
if (null !== ($response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE))) {
return $response;
}
ConfigQuery::create()->filterByName('one_domain_foreach_lang')->update(array('Value' => $activate));
return $this->generateRedirectFromRoute('admin.configuration.languages');
}
示例15: doInsert
/**
* Performs an INSERT on the database, given a Config or Criteria object.
*
* @param mixed $criteria Criteria or Config object containing data that is used to create the INSERT statement.
* @param ConnectionInterface $con the ConnectionInterface connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($criteria, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(ConfigTableMap::DATABASE_NAME);
}
if ($criteria instanceof Criteria) {
$criteria = clone $criteria;
// rename for clarity
} else {
$criteria = $criteria->buildCriteria();
// build Criteria from Config object
}
if ($criteria->containsKey(ConfigTableMap::ID) && $criteria->keyContainsValue(ConfigTableMap::ID)) {
throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConfigTableMap::ID . ')');
}
// Set the correct dbName
$query = ConfigQuery::create()->mergeWith($criteria);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->beginTransaction();
$pk = $query->doInsert($con);
$con->commit();
} catch (PropelException $e) {
$con->rollBack();
throw $e;
}
return $pk;
}