Beispiel #1
0
 public function testCreate()
 {
     $session = $this->getTestSession();
     $this->assertTrue(0 < $session->getId(), 'check session id');
     foreach ($this->testSession as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $session->{$m}(), 'Check ' . $k);
     }
 }
Beispiel #2
0
 /**
  * testCreate
  *
  * @return void
  * @see    ____func_see____
  * @since  1.0.22
  */
 public function testCreate()
 {
     $method = $this->getTestMethod();
     $this->assertTrue(0 < $method->getMethodId(), 'check method id');
     foreach ($this->testMethod as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $method->{$m}(), 'Check ' . $k);
     }
 }
Beispiel #3
0
 /**
  * Get entity value
  *
  * @return mixed
  */
 protected function getEntityValue()
 {
     $result = null;
     $entity = $this->getEntity();
     $method = 'get' . \XLite\Core\Converter::convertToCamelCase($this->getParam(static::PARAM_FIELD_NAME));
     if (method_exists($entity, $method)) {
         // $method assembled from 'get' + field short name
         $result = $this->getEntity()->{$method}();
     }
     return $result;
 }
Beispiel #4
0
 /**
  * Preprocessor for no-action run
  *
  * @return void
  */
 protected function doNoAction()
 {
     $dictionary = \XLite\Core\Request::getInstance()->dictionary;
     if ($dictionary) {
         $method = 'assembleDictionary' . \XLite\Core\Converter::convertToCamelCase($dictionary);
         if (method_exists($this, $method)) {
             $this->data = $this->processData($this->{$method}(strval(\XLite\Core\Request::getInstance()->erm)));
         }
     }
     $this->silent = true;
 }
Beispiel #5
0
 public function testCreate()
 {
     $group = $this->getTestGroup();
     $this->assertEquals(3, count($group->getOptions()), 'Check options count');
     $options = $group->getOptions();
     $option = $options[0];
     foreach ($this->testOption as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $option->{$m}(), 'Check ' . $k . ' (option)');
     }
     $this->assertEquals(10, $options[2]->getSurcharge('price')->getModifier(), 'Check modifier');
     $this->assertEquals('$', $options[2]->getSurcharge('price')->getModifierType(), 'Check modifier type');
     $this->assertEquals(1, $options[2]->getExceptions()->count(), 'Check exceptions');
 }
Beispiel #6
0
 /**
  * Add options to HTML Purifier config
  *
  * @param \HTMLPurifier_Config $config Config instance
  *
  * @return \HTMLPurifier_Config
  */
 public static function addConfigOptions($config, $options)
 {
     foreach ($options as $name => $value) {
         if ('1' == $value) {
             $value = true;
         } elseif ('0' == $value) {
             $value = false;
         }
         $method = 'prepareOptionValue' . \XLite\Core\Converter::convertToCamelCase(str_replace('.', '', $name));
         if (method_exists(static::getInstance(), $method)) {
             $value = static::$method($value);
         }
         if (!is_null($value)) {
             $config->set($name, $value);
         }
     }
     $config = static::postprocessOptions($config, $options);
     return $config;
 }
Beispiel #7
0
 /**
  * testCreate
  *
  * @return void
  * @see    ____func_see____
  * @since  1.0.13
  */
 public function testCreate()
 {
     $c = $this->currency;
     $this->assertTrue(0 < $c->getCurrencyId(), 'check currency id');
     foreach ($this->testData as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $c->{$m}(), 'Check ' . $k);
     }
     $o = $this->getTestOrder();
     $o->setCurrency($c);
     $c->addOrders($o);
     $this->assertEquals($o, $c->getOrders()->get(0), 'check order');
     try {
         $this->getTestCurrency(true);
         $this->fail('check code unique failed');
     } catch (\PDOException $e) {
         $this->assertRegExp('/SQLSTATE\\[23000\\]/', $e->getMessage(), 'check code unique');
     }
 }
Beispiel #8
0
 /**
  * Define columns
  *
  * @return array
  */
 protected function defineColumns()
 {
     $columns = array('orderNumber' => array(), static::CUSTOMER_PREFIX . 'Email' => array(), static::CUSTOMER_PREFIX . 'Anonymous' => array(), static::CUSTOMER_PREFIX . 'AddressSame' => array());
     foreach (\XLite\Core\Database::getRepo('XLite\\Model\\AddressField')->findAllEnabled() as $field) {
         $name = ucfirst(\XLite\Core\Converter::convertToCamelCase($field->getServiceName()));
         $columns[static::CUSTOMER_PREFIX . $name . 'Billing' . static::ADDRESS_FIELD_SUFFIX] = array(static::COLUMN_GETTER => 'getBillingAddressFieldValue', static::COLUMN_FORMATTER => 'formatBillingAddressFieldValue', 'service_name' => $field->getServiceName());
     }
     foreach (\XLite\Core\Database::getRepo('XLite\\Model\\AddressField')->findAllEnabled() as $field) {
         $name = ucfirst(\XLite\Core\Converter::convertToCamelCase($field->getServiceName()));
         $columns[static::CUSTOMER_PREFIX . $name . 'Shipping' . static::ADDRESS_FIELD_SUFFIX] = array(static::COLUMN_GETTER => 'getShippingAddressFieldValue', static::COLUMN_FORMATTER => 'formatShippingAddressFieldValue', 'service_name' => $field->getServiceName());
     }
     $columns += array(static::ITEM_PREFIX . 'Name' => array(static::COLUMN_MULTIPLE => true), static::ITEM_PREFIX . 'SKU' => array(static::COLUMN_MULTIPLE => true), static::ITEM_PREFIX . 'Attributes' => array(static::COLUMN_MULTIPLE => true), static::ITEM_PREFIX . 'Price' => array(static::COLUMN_MULTIPLE => true), static::ITEM_PREFIX . 'Quantity' => array(static::COLUMN_MULTIPLE => true), static::ITEM_PREFIX . 'Subtotal' => array(static::COLUMN_MULTIPLE => true));
     foreach ($this->getOrderItemSurchargeTypes() as $type) {
         $columns[$type['name'] . ' (item surcharge)'] = array('type' => $type, static::COLUMN_GETTER => 'getOrderItemSurchargeColumnValue', static::COLUMN_MULTIPLE => true);
     }
     $columns += array(static::ITEM_PREFIX . 'Total' => array(static::COLUMN_MULTIPLE => true), 'subtotal' => array());
     foreach ($this->getOrderSurchargeTypes() as $type) {
         $columns[$type['name'] . ' (surcharge)'] = array('type' => $type, static::COLUMN_GETTER => 'getOrderSurchargeColumnValue');
     }
     $columns += array('total' => array(), 'currency' => array(), 'shippingMethod' => array(), 'trackingNumber' => array(), static::PAYMENT_TRANSACTION_PREFIX . 'Method' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Status' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Value' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Note' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Type' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Id' => array(static::COLUMN_MULTIPLE => true), static::PAYMENT_TRANSACTION_PREFIX . 'Data' => array(static::COLUMN_MULTIPLE => true), 'date' => array(), 'paymentStatus' => array(), 'shippingStatus' => array(), 'notes' => array(), 'adminNotes' => array(), 'detailCode' => array(static::COLUMN_MULTIPLE => true), 'detailLabel' => array(static::COLUMN_MULTIPLE => true), 'detailValue' => array(static::COLUMN_MULTIPLE => true));
     return $columns;
 }
Beispiel #9
0
 /**
  * testConstruct
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testConstruct()
 {
     $dataToSet = array();
     $dataToCheck = array();
     foreach ($this->getProductData() as $key => $data) {
         list($actual, $expected) = $data;
         $dataToSet[$key] = $actual;
         $dataToCheck[$key] = isset($expected) ? $expected : $actual;
     }
     $entity = new \XLite\Model\Product($dataToSet);
     foreach ($dataToCheck as $key => $value) {
         $this->assertEquals($value, $entity->{'get' . \XLite\Core\Converter::convertToCamelCase($key)}(), 'Field "' . $key . '" does not match');
     }
     // Order item
     $i = new \XLite\Model\OrderItem();
     $entity->addOrderItems($i);
     $this->assertEquals($i, $entity->getOrderItems()->get(0), 'check order item');
     // Image
     $i = new \XLite\Model\Image\Product\Image();
     $entity->addImages($i);
     $this->assertEquals($i, $entity->getImages()->get(0), 'check image');
 }
Beispiel #10
0
 /**
  * testCreate
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testCreate()
 {
     $order = $this->getTestOrder();
     $this->assertTrue(0 < $order->getOrderId(), 'check order id');
     foreach ($order as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $order->{$m}(), 'Check test order: ' . $k);
     }
     $this->assertEquals($this->getProduct()->getProductId(), $order->getItems()->get(0)->getObject()->getProductId(), 'check product id');
     $this->assertEquals('Purchase Order', $order->getPaymentMethod()->getName(), 'check payment method');
     $this->assertFalse(is_null($order->getProfile()), 'check profile');
     $this->assertFalse(is_null($order->getProfile()->getOrder()), 'check profile\'s order');
     $this->assertEquals($order->getOrderId(), $order->getProfile()->getOrder()->getOrderId(), 'check profile\'s order id');
     $this->assertTrue(0 < $order->getDate(), 'check date');
     $shippingCost = $order->getSurchargeSumByType('shipping');
     $this->assertEquals(1, $order->getItems()->get(0)->getAmount(), 'check quantity');
     $this->assertEquals($this->getProduct()->getPrice(), $order->getItems()->get(0)->getPrice(), 'check price');
     $this->assertEquals($this->getProduct()->getPrice(), $order->getItems()->get(0)->getSubtotal(), 'check item subtotal');
     $this->assertEquals($this->getProduct()->getPrice(), $order->getSubtotal(), 'check order subtotal');
     $this->assertEquals(round($shippingCost + $this->getProduct()->getPrice(), 2), $order->getTotal(), 'check total');
     // Payment method
     $pm = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findOneBy(array('service_name' => 'PurchaseOrder'));
     $order->setPaymentMethod($pm);
     $this->assertEquals($pm, $order->getPaymentMethod(), 'check payment method');
     // Saved modifiers
     $surcharge = new \XLite\Model\Order\Surcharge();
     $surcharge->setType('shipping');
     $surcharge->setCode('ttt');
     $surcharge->setValue(10.0);
     $surcharge->setInclude(false);
     $surcharge->setAvailable(true);
     $surcharge->setClass(get_called_class());
     $surcharge->setName('test');
     $order->getSurcharges()->add($surcharge);
     $surcharge->setOwner($order);
     $count = count($order->getSurcharges());
     $this->assertEquals($surcharge, $order->getSurcharges()->get($count - 1), 'check surcharge');
 }
Beispiel #11
0
 /**
  * Get help
  *
  * @return string
  */
 protected function getHelp()
 {
     $help = null;
     $action = \XLite\Core\Request::getInstance()->action;
     if ($action) {
         $method = 'getHelp' . \XLite\Core\Converter::convertToCamelCase($action);
         $help = method_exists($this, $method) ? $this->{$method}() : 'Action \'' . $action . '\' has not help note';
     } else {
         $help = $this->getControllerHelp();
     }
     return $help;
 }
Beispiel #12
0
 /**
  * Create field widget
  *
  * @param string $name Field name
  * @param array  $data Field data
  *
  * @return \XLite\View\FormField\AFormField
  */
 protected function getFieldBySchema($name, array $data)
 {
     $result = null;
     $class = $data[\XLite\View\Model\Address\Address::SCHEMA_CLASS];
     if (\XLite\Core\Operator::isClassExists($class)) {
         $method = 'prepareFieldParams' . \XLite\Core\Converter::convertToCamelCase($name);
         if (method_exists($this, $method)) {
             $data = $this->{$method}($data);
         }
         $result = new $class($this->getFieldSchemaArgs($name, $data));
     }
     return $result;
 }
Beispiel #13
0
 /**
  * Preprocess option change and return true on success
  *
  * @param \XLite\Model\Config $option Option entity
  *
  * @return boolean
  */
 protected function preprocessOption($option)
 {
     $result = true;
     $method = 'preprocess' . \XLite\Core\Converter::convertToCamelCase($option->name) . 'Option';
     if (method_exists($this, $method)) {
         $result = $this->{$method}($option);
     }
     return $result;
 }
Beispiel #14
0
 /**
  * Postprocess surcharge
  *
  * @param float $surcharge Surcharge
  *
  * @return mixed
  */
 protected function postprocessSurcharge($surcharge)
 {
     static $methodNames = array();
     $type = $this->getType();
     if (!isset($methodNames[$type])) {
         $name = 'postprocessSurcharge' . \XLite\Core\Converter::convertToCamelCase($this->getType());
         $methodNames[$type] = method_exists($this, $name) ? $name : false;
     }
     return $methodNames[$type] ? $this->{$methodNames[$type]}($surcharge) : $surcharge;
 }
Beispiel #15
0
 /**
  * Calculated and create Canada Post parcels for the order
  *
  * @param boolean $replace Flag - replace order's parcels or not
  *
  * @return void
  */
 public function createCapostParcels($replace = false)
 {
     $modifier = $this->getModifier(\XLite\Model\Base\Surcharge::TYPE_SHIPPING, 'SHIPPING');
     $rawPackages = $modifier && $modifier->getMethod() && $modifier->getMethod()->getProcessorObject() ? $modifier->getMethod()->getProcessorObject()->getPackages($modifier) : array();
     $capostConfig = \XLite\Core\Config::getInstance()->XC->CanadaPost;
     if ($replace) {
         // Remove order's parcels
         $this->removeAllCapostParcels();
     }
     if (!empty($rawPackages) && is_array($rawPackages)) {
         foreach ($rawPackages as $packageIdx => $package) {
             $parcel = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel();
             $parcel->setOrder($this);
             $parcel->setNumber($packageIdx + 1);
             $parcel->setQuoteType($capostConfig->quote_type);
             // Set parcel box dimensions and weight
             foreach (array('weight', 'length', 'width', 'height') as $_param) {
                 $parcel->{'setBox' . \XLite\Core\Converter::convertToCamelCase($_param)}($package['box'][$_param]);
             }
             // Set parcel types (DEFAULT)
             foreach (array('document', 'unpackaged', 'mailing_tube', 'oversized') as $_param) {
                 $parcel->{'setIs' . \XLite\Core\Converter::convertToCamelCase($_param)}($capostConfig->{$_param});
             }
             // Set default parcel options (from the module settings)
             $optClasses = $parcel->getAllowedOptionClasses();
             foreach ($optClasses as $optClass => $classData) {
                 if ($parcel::OPT_CLASS_COVERAGE == $optClass) {
                     // Do not use default settings for "coverage"
                     continue;
                 }
                 // Set default option value from module settings
                 $value = isset($capostConfig->{$optClass}) ? $capostConfig->{$optClass} : '';
                 if ($classData[$parcel::OPT_SCHEMA_MULTIPLE] && $classData[$parcel::OPT_SCHEMA_MANDATORY] && !isset($classData[$parcel::OPT_SCHEMA_ALLOWED_OPTIONS][$value])) {
                     // Set allowed option value
                     $value = array_shift(array_keys($classData[$parcel::OPT_SCHEMA_ALLOWED_OPTIONS]));
                 }
                 $parcel->{'setOpt' . \XLite\Core\Converter::convertToCamelCase($optClass)}($value);
             }
             // Add items to the parcel
             foreach ($package['items'] as $itemIdx => $item) {
                 $parcelItem = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Item();
                 $parcelItem->setAmount($item['qty']);
                 $parcelItem->setOrderItem($this->getItemById($item['id']));
                 // Assign parcel to the order
                 $parcel->addItem($parcelItem);
             }
             // Assign parcel to the order
             $this->addCapostParcel($parcel);
             \XLite\Core\Database::getEM()->persist($parcel);
         }
         \XLite\Core\Database::getEM()->flush();
     }
 }
Beispiel #16
0
 /**
  * Get timestamp of current day start
  *
  * @return integer
  */
 protected function getStartTime($interval = self::P_ALL)
 {
     $methodName = 'get' . \XLite\Core\Converter::convertToCamelCase($interval) . 'StartTime';
     return method_exists($this, $methodName) ? call_user_func(array($this, $methodName)) : $this->getDefaultStartTime();
 }
Beispiel #17
0
 /**
  * Get model value by name
  *
  * @param \XLite\Model\AEntity $model Model object
  * @param string               $name  Property name
  *
  * @return mixed
  */
 protected function getModelValue($model, $name)
 {
     $method = 'get' . \XLite\Core\Converter::convertToCamelCase($name);
     // $method - assemble from 'get' + property name
     return $model->{$method}();
 }
Beispiel #18
0
 /**
  * Convert XML files name to camel case
  *
  * @param string $field XML field name
  *
  * @return string
  */
 public static function convertXmlFieldToCamelCase($field)
 {
     return lcfirst(\XLite\Core\Converter::convertToCamelCase(str_replace('-', '_', $field)));
 }
Beispiel #19
0
 /**
  * Truncates the baseObject property value to specified length
  *
  * @param mixed   $base       String or object instance to get field value from
  * @param mixed   $field      String length or field to get value
  * @param integer $length     Field length to truncate to OPTIONAL
  * @param string  $etc        String to add to truncated field value OPTIONAL
  * @param mixed   $breakWords Word wrap flag OPTIONAL
  *
  * @return string
  */
 protected function truncate($base, $field, $length = 0, $etc = '...', $breakWords = false)
 {
     if (is_scalar($base)) {
         $string = $base;
         $length = $field;
     } else {
         if ($base instanceof \XLite\Model\AEntity) {
             $string = $base->{'get' . \XLite\Core\Converter::convertToCamelCase($field)}();
         } else {
             $string = $base->get($field);
         }
     }
     if (0 == $length) {
         $string = '';
     } elseif (strlen($string) > $length) {
         $length -= strlen($etc);
         if (!$breakWords) {
             $string = preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, $length + 1));
         }
         $string = substr($string, 0, $length) . $etc;
     }
     return $string;
 }
Beispiel #20
0
 /**
  * getFieldBySchema
  * TODO - should use the Factory class
  *
  * @param string $name Field name
  * @param array  $data Field description
  *
  * @return \XLite\View\FormField\AFormField
  */
 protected function getFieldBySchema($name, array $data)
 {
     $class = $data[self::SCHEMA_CLASS];
     $method = 'prepareFieldParams' . \XLite\Core\Converter::convertToCamelCase($name);
     if (method_exists($this, $method)) {
         // Call the corresponded method
         $this->{$method}($data);
     }
     return new $class($this->getFieldSchemaArgs($name, $data));
 }
Beispiel #21
0
 /**
  * testCreate
  *
  * @return void
  * @see    ____func_see____
  * @since  1.0.22
  */
 public function testCreate()
 {
     $group = $this->getTestGroup();
     $this->assertTrue(0 < $group->getGroupId(), 'check group id type');
     foreach ($this->testGroup as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $group->{$m}(), 'Check ' . $k);
     }
     $this->assertEquals($this->getProduct()->getProductId(), $group->getProduct()->getProductId(), 'check product id');
     $this->assertEquals(1, count($group->getOptions()), 'Check options count');
     $options = $group->getOptions();
     $option = $options[0];
     foreach ($this->testOption as $k => $v) {
         $m = 'get' . \XLite\Core\Converter::convertToCamelCase($k);
         $this->assertEquals($v, $option->{$m}(), 'Check ' . $k . ' (option)');
     }
 }
Beispiel #22
0
 /**
  * test
  *
  * @return void
  * @access public
  * @see    ____func_see____
  * @since  1.0.0
  */
 public function testInsert()
 {
     $data = array('enabled' => false, 'name' => 'Test category', 'cleanURL' => 'test_cat');
     $entity = $this->getRepo()->insert($data);
     $entity->setParent($this->getRepo()->find(14016));
     $this->assertInstanceOf('\\XLite\\Model\\Category', $entity, 'Created entity must be of the "\\XLite\\Model\\Category" type');
     foreach ($data as $name => $value) {
         $this->assertEquals($value, $entity->{'get' . \XLite\Core\Converter::convertToCamelCase($name)}(), 'The "' . $name . '" property of the created entity must be equal to "' . $value . '"');
     }
 }
Beispiel #23
0
 /**
  * Main 'Select' action handler.
  *  - calls "doActionSelect<file_select_action><object><file_object>()" handler
  *  - set return URL which is set by "getParamsObject<object>()" getter
  *
  * @return void
  */
 protected function doActionSelect()
 {
     $actionName = 'doActionSelect' . \XLite\Core\Converter::convertToCamelCase(\XLite\Core\Request::getInstance()->file_select) . \XLite\Core\Converter::convertToCamelCase($this->getObjectTarget()) . \XLite\Core\Converter::convertToCamelCase(\XLite\Core\Request::getInstance()->fileObject);
     if (method_exists($this, $actionName)) {
         call_user_func(array($this, $actionName));
     }
     $returnURL = $this->forceReturnURL ?: $this->buildURL($this->getRedirectTarget(), '', $this->getParamsObject());
     $this->setReturnURL($returnURL);
 }
Beispiel #24
0
 /**
  * Get product data as REST
  *
  * @param integer $id Product id
  *
  * @return array
  */
 public function getProductREST($id)
 {
     $product = $this->find($id);
     $data = null;
     if ($product) {
         foreach ($this->_class->fieldNames as $name) {
             $mname = 'get' . \XLite\Core\Converter::convertToCamelCase($name);
             // $maname assebmled from 'get' + \XLite\Core\Converter::convertToCamelCase() method
             $data[$name] = $product->{$mname}();
         }
         $data['name'] = $product->getName();
         $data['description'] = $product->getDescription();
     }
     return $data;
 }
Beispiel #25
0
 /**
  * Get cell cache parameters converter method name
  *
  * @param string $name Cell name
  *
  * @return string
  */
 protected function getCacheParamsConverterName($name)
 {
     return 'convertRecordToParams' . \XLite\Core\Converter::convertToCamelCase($name);
 }
Beispiel #26
0
 /**
  * Call "Get Maifest" request
  *
  * @return boolean
  */
 public function callApiGetManifest()
 {
     $result = false;
     $data = \XLite\Module\XC\CanadaPost\Core\API::getInstance()->callGetManifestRequest($this);
     if (isset($data->errors)) {
         // Save errors
         $this->apiCallErrors = $data->errors;
     } else {
         sleep(2);
         // to get Canada Post server time to generate PDF documents
         $this->setPoNumber($data->poNumber);
         foreach ($data->links as $link) {
             $manifestLink = new \XLite\Module\XC\CanadaPost\Model\Order\Parcel\Manifest\Link();
             $manifestLink->setManifest($this);
             $this->addLink($manifestLink);
             foreach (array('rel', 'href', 'mediaType', 'idx') as $linkField) {
                 if (isset($link->{$linkField})) {
                     $manifestLink->{'set' . \XLite\Core\Converter::convertToCamelCase($linkField)}($link->{$linkField});
                 }
             }
             if (!$manifestLink->callApiGetArtifact() && $manifestLink->getApiCallErrors()) {
                 // Error is occurred while downloading PDF documents
                 if (!isset($this->apiCallErrors)) {
                     $this->apiCallErrors = array();
                 }
                 $this->apiCallErrors += $manifestLink->getApiCallErrors();
             }
         }
         \XLite\Core\Database::getEM()->flush();
         $result = true;
     }
     return $result;
 }
Beispiel #27
0
 /**
  * Get model value by name
  *
  * @param \XLite\Model\AEntity $model Model object
  * @param string               $name  Property name
  *
  * @return mixed
  */
 protected function getModelValue($model, $name)
 {
     $method = 'get' . \XLite\Core\Converter::convertToCamelCase($name);
     // $method - assemble from 'get' + property name
     return method_exists($model, $method) ? $model->{$method}() : ($model->isPropertyExists($name) ? $model->getterProperty($name) : null);
 }
Beispiel #28
0
 /**
  * Prepare column handler
  *
  * @param array  $column  Column info
  * @param string $name    Column cell name
  * @param string $pattern Handler name pattern
  *
  * @return mixed
  */
 protected function prepareColumnHandler(array $column, $name, $pattern)
 {
     $result = null;
     if (empty($column[$name])) {
         $uname = \XLite\Core\Converter::convertToCamelCase($column[static::COLUMN_NAME]);
         $method = str_replace('{name}', $uname, $pattern);
         if (method_exists($this, $method)) {
             $result = $method;
         }
     } elseif (true === $column[$name]) {
         $uname = \XLite\Core\Converter::convertToCamelCase($column[static::COLUMN_NAME]);
         $result = str_replace('{name}', $uname, $pattern);
     } elseif (is_callable($column[$name])) {
         $result = $column[$name];
     }
     return $result;
 }
Beispiel #29
0
 /**
  * Get create line columns
  *
  * @return array
  */
 protected function getCreateColumns()
 {
     $columns = array();
     if ($this->getLeftActions()) {
         $columns[] = array(static::COLUMN_CODE => 'actions left', static::COLUMN_NAME => '', static::COLUMN_SERVICE => true, static::COLUMN_TEMPLATE => 'items_list/model/table/parts/empty_left.tpl');
     }
     foreach ($this->defineColumns() as $idx => $column) {
         if (isset($column[static::COLUMN_CREATE_CLASS]) && $column[static::COLUMN_CREATE_CLASS] || isset($column[static::COLUMN_CLASS]) && $column[static::COLUMN_CLASS]) {
             $column[static::COLUMN_CODE] = $idx;
             $column[static::COLUMN_METHOD_SUFFIX] = \XLite\Core\Converter::convertToCamelCase($column[static::COLUMN_CODE]);
             if (!isset($column[static::COLUMN_CREATE_CLASS]) || !$column[static::COLUMN_CREATE_CLASS]) {
                 $column[static::COLUMN_CREATE_CLASS] = $column[static::COLUMN_CLASS];
             }
             $columns[] = $column;
         } else {
             $columns[] = array(static::COLUMN_CODE => $idx, static::COLUMN_TEMPLATE => 'items_list/model/table/empty.tpl');
         }
     }
     if ($this->getRightActions()) {
         $columns[] = array(static::COLUMN_CODE => 'actions right', static::COLUMN_NAME => '', static::COLUMN_SERVICE => true, static::COLUMN_TEMPLATE => $this->isRemoved() ? 'items_list/model/table/parts/remove_create.tpl' : 'items_list/model/table/parts/empty_right.tpl');
     }
     return $columns;
 }
Beispiel #30
0
 /**
  * Get entity
  *
  * @return \XLite\Model\AEntity
  */
 public function getEntity()
 {
     $entity = null;
     foreach (\XLite\Model\Repo\CleanURL::getEntityTypes() as $type) {
         $method = 'get' . \XLite\Core\Converter::convertToCamelCase($type);
         if (method_exists($this, $method)) {
             $entity = $this->{$method}();
             if ($entity) {
                 break;
             }
         }
     }
     return $entity;
 }