/**
  * Validate Content
  *
  * @param BaseElementModel $element Element
  *
  * @return void
  */
 private function validateContentModel(BaseElementModel $element)
 {
     $fields_key = \Craft\craft()->config->get('contentModelFieldsLocation', 'restfulApi');
     if (!\Craft\craft()->content->validateContent($element)) {
         $this->addErrors([$fields_key => $element->getContent()->getErrors()]);
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 3
     $context["elementTypeClass"] = $this->getContext($context, "elementType");
     // line 4
     $context["elementType"] = $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "elements"), "getElementType", array(0 => $this->getContext($context, "elementTypeClass")), "method");
     // line 5
     $context["context"] = "index";
     // line 7
     if (!$this->getContext($context, "elementType")) {
         // line 8
         throw new \Craft\HttpException(404);
     }
     // line 11
     $context["sources"] = $this->getAttribute($this->getContext($context, "elementType"), "getSources", array(0 => "index"), "method");
     // line 23
     ob_start();
     // line 24
     echo "\t<div class=\"elementindex\">\n\t\t";
     // line 25
     $this->env->loadTemplate("_elements/indexcontainer")->display($context);
     // line 26
     echo "\t</div>\n";
     $context["content"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 40
     \Craft\craft()->templates->includeJs($this->renderBlock("initJs", $context, $blocks));
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 public function isConfigured()
 {
     $oauthProvider = \Craft\craft()->oauth->getProvider($this->getHandle());
     if ($oauthProvider) {
         return $oauthProvider->isConfigured();
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 2
     $context["forms"] = $this->env->loadTemplate("_includes/forms");
     // line 4
     ob_start();
     // line 5
     echo "\t";
     if ($this->getAttribute($this->getContext($context, "entry"), "id") && $this->getContext($context, "CraftEdition") >= $this->getContext($context, "CraftClient")) {
         // line 6
         echo "\t\t";
         $this->env->loadTemplate("entries/_revisions")->display($context);
         // line 7
         echo "\t";
     }
     $context["extraPageHeaderHtml"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 10
     $context["sectionHandle"] = $this->getAttribute($this->getContext($context, "section"), "handle");
     // line 201
     if (!$this->getAttribute($this->getContext($context, "entry"), "slug")) {
         // line 202
         \Craft\craft()->templates->includeJs("window.slugGenerator = new Craft.SlugGenerator('#title', '#slug');");
     }
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
Beispiel #5
0
 /**
  * Constructor
  *
  * @param int $accountId
  *
  * @return null
  */
 public function __construct($accountId)
 {
     $this->account = \Craft\craft()->social_loginAccounts->getLoginAccountById($accountId);
     if ($this->account) {
         $this->_userModel = $this->account->getUser();
     }
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 2
     $context["title"] = \Craft\Craft::t("Entries");
     // line 3
     $context["elementType"] = "Entry";
     // line 6
     $context["sections"] = $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "sections"), "getEditableSections", array(), "method");
     // line 7
     $context["newEntrySections"] = array();
     // line 9
     $context['_parent'] = (array) $context;
     $context['_seq'] = twig_ensure_traversable($this->getContext($context, "sections"));
     foreach ($context['_seq'] as $context["_key"] => $context["section"]) {
         // line 10
         if ($this->getAttribute($this->getContext($context, "section"), "type") != "single" && $this->getAttribute($this->getContext($context, "currentUser"), "can", array(0 => "createEntries:" . $this->getAttribute($this->getContext($context, "section"), "id")), "method")) {
             // line 11
             $context["newEntrySections"] = twig_array_merge($this->getContext($context, "newEntrySections"), array(0 => $this->getContext($context, "section")));
         }
     }
     $_parent = $context['_parent'];
     unset($context['_seq'], $context['_iterated'], $context['_key'], $context['section'], $context['_parent'], $context['loop']);
     $context = array_intersect_key($context, $_parent) + $_parent;
     // line 38
     if (array_key_exists("sectionHandle", $context)) {
         // line 39
         \Craft\craft()->templates->includeJs("window.defaultSectionHandle = \"" . $this->getContext($context, "sectionHandle") . "\";");
     }
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 /**
  * Include Content
  *
  * @param BaseElementModel $element Element
  *
  * @return League\Fractal\Resource\Item Content
  */
 public function includeContent(BaseElementModel $element)
 {
     $content = [];
     if ($this->depth > \Craft\craft()->config->get('contentRecursionLimit', 'httpMessagesRestMiddleware') - 1) {
         return;
     }
     foreach ($element->getFieldLayout()->getFields() as $fieldLayoutField) {
         $field = $fieldLayoutField->getField();
         $value = $element->getFieldValue($field->handle);
         if (get_class($field->getFieldType()) === 'Craft\\RichTextFieldType') {
             $value = $value->getRawContent();
         }
         if (is_object($value) && get_class($value) === 'Craft\\ElementCriteriaModel') {
             $class = get_class($value->getElementType());
             $element_type = $this->element_service->getElementTypeByClass($class);
             $manager = new Manager();
             $manager->parseIncludes(array_merge(['content'], explode(',', \Craft\craft()->request->getParam('include'))));
             $manager->setSerializer(new ArraySerializer());
             $transformer = $this->config_service->getTransformer($element_type);
             $value = $value->find();
             $body = new Collection($value, new $transformer($this->depth + 1));
             $value = $manager->createData($body)->toArray();
             $value = !empty($value['data']) ? $value['data'] : null;
         }
         $content[$field->handle] = $value;
     }
     if ($content) {
         return $this->item($content, new ContentTransformer($this->depth), 'content');
     }
 }
 /**
  * With Criteria
  *
  * @param Request $request Request
  *
  * @return RestRequest RestRequest
  */
 private function withCriteria(Request $request)
 {
     $element_type = $request->getAttribute('elementType');
     $element_id = $request->getAttribute('elementId');
     $attributes = array_merge($request->getQueryParams(), $request->getAttributes());
     $criteria = \Craft\craft()->elements->getCriteria($element_type, $attributes);
     $pagination_parameter = \Craft\craft()->config->get('paginationParameter', 'restfulApi');
     if (isset($criteria->{$pagination_parameter})) {
         $criteria->offset = ($criteria->{$pagination_parameter} - 1) * $criteria->limit;
         unset($criteria->{$pagination_parameter});
     }
     if ($element_id) {
         $criteria->archived = null;
         $criteria->fixedOrder = null;
         $criteria->limit = 1;
         $criteria->localeEnabled = false;
         $criteria->offset = 0;
         $criteria->order = null;
         $criteria->status = null;
         $criteria->editable = null;
         if (is_numeric($element_id)) {
             $criteria->id = $element_id;
         } else {
             $criteria->slug = $element_id;
         }
     }
     return $request->withCriteria($criteria);
 }
 /**
  * Handle
  *
  * @param Request $request Request
  * @param Response $response Response
  *
  * @return Response Response
  */
 public function handle(HttpMessages_CraftRequest $request, HttpMessages_CraftResponse $response)
 {
     $relay = new RelayBuilder();
     $globalMiddleware = \Craft\craft()->config->get('globalMiddleware', 'httpmessages');
     $routeMiddleware = $request->getRoute()->getMiddleware();
     $dispatcher = $relay->newInstance(array_merge($globalMiddleware, $routeMiddleware));
     return $dispatcher($request, $response);
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     if (!array_key_exists("value", $context)) {
         // line 2
         $context["value"] = null;
     }
     // line 5
     $context["id"] = $this->getContext($context, "id") . "-time";
     // line 7
     if (array_key_exists("name", $context) && $this->getContext($context, "name")) {
         // line 8
         $context["name"] = $this->getContext($context, "name") . "[time]";
     }
     // line 11
     \Craft\craft()->templates->includeJsResource("lib/jquery.timepicker/jquery.timepicker" . ($this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "useCompressedJs") ? ".min" : "") . ".js");
     // line 13
     if (!array_key_exists("value", $context)) {
         // line 14
         $context["value"] = null;
     }
     // line 17
     echo "<div class=\"timewrapper\">";
     // line 18
     $this->env->loadTemplate("_includes/forms/text")->display(array_merge($context, array("autocomplete" => false, "size" => 10, "value" => $this->getContext($context, "value") ? $this->getAttribute($this->getContext($context, "value"), "localeTime", array(), "method") : "")));
     // line 19
     echo "</div>";
     // line 21
     $context["localeData"] = $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "i18n"), "getLocaleData", array(), "method");
     // line 23
     ob_start();
     // line 24
     echo "\n\tvar \$timePicker = \$('#";
     // line 25
     echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\craft()->templates->namespaceInputId($this->getContext($context, "id")), "js"), "html", null, true);
     echo "');\n\t\$timePicker.timepicker({\n\t\ttimeFormat: '";
     // line 27
     echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "i18n"), "timepickerJsFormat"), "html", null, true);
     echo "',\n\t\tcloseOnWindowScroll: false,\n\t\torientation: '";
     // line 29
     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "localeData"), "getOrientation", array(), "method"), "html", null, true);
     echo "',\n\t\tlang: {\n\t\t\tam: '";
     // line 31
     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "localeData"), "getAMName", array(), "method"), "html", null, true);
     echo "',\n\t\t\tAM: '";
     // line 32
     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "localeData"), "getAMName", array(), "method"), "html", null, true);
     echo "',\n\t\t\tpm: '";
     // line 33
     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "localeData"), "getPMName", array(), "method"), "html", null, true);
     echo "',\n\t\t\tPM: '";
     // line 34
     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "localeData"), "getPMName", array(), "method"), "html", null, true);
     echo "'\n\t\t}\n\t});";
     $context["js"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 39
     \Craft\craft()->templates->includeJs($this->getContext($context, "js"));
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     if (!array_key_exists("element", $context)) {
         $context["element"] = null;
     }
     // line 2
     if (!array_key_exists("namespace", $context)) {
         $context["namespace"] = "fields";
     }
     // line 3
     echo "\n";
     // line 4
     $_namespace = $this->getContext($context, "namespace");
     if ($_namespace) {
         $_originalNamespace = \Craft\craft()->templates->getNamespace();
         \Craft\craft()->templates->setNamespace(\Craft\craft()->templates->namespaceInputName($_namespace));
         ob_start();
         try {
             // line 5
             echo "\t";
             $context['_parent'] = (array) $context;
             $context['_seq'] = twig_ensure_traversable($this->getContext($context, "fields"));
             foreach ($context['_seq'] as $context["_key"] => $context["field"]) {
                 // line 6
                 echo "\t\t";
                 $this->env->loadTemplate("_includes/field")->display(array("field" => $this->getAttribute($this->getContext($context, "field"), "getField", array(), "method"), "required" => $this->getAttribute($this->getContext($context, "field"), "required"), "element" => $this->getContext($context, "element")));
                 // line 11
                 echo "\t";
             }
             $_parent = $context['_parent'];
             unset($context['_seq'], $context['_iterated'], $context['_key'], $context['field'], $context['_parent'], $context['loop']);
             $context = array_intersect_key($context, $_parent) + $_parent;
         } catch (Exception $e) {
             ob_end_clean();
             throw $e;
         }
         echo \Craft\craft()->templates->namespaceInputs(ob_get_clean(), $_namespace);
         \Craft\craft()->templates->setNamespace($_originalNamespace);
     } else {
         // line 5
         echo "\t";
         $context['_parent'] = (array) $context;
         $context['_seq'] = twig_ensure_traversable($this->getContext($context, "fields"));
         foreach ($context['_seq'] as $context["_key"] => $context["field"]) {
             // line 6
             echo "\t\t";
             $this->env->loadTemplate("_includes/field")->display(array("field" => $this->getAttribute($this->getContext($context, "field"), "getField", array(), "method"), "required" => $this->getAttribute($this->getContext($context, "field"), "required"), "element" => $this->getContext($context, "element")));
             // line 11
             echo "\t";
         }
         $_parent = $context['_parent'];
         unset($context['_seq'], $context['_iterated'], $context['_key'], $context['field'], $context['_parent'], $context['loop']);
         $context = array_intersect_key($context, $_parent) + $_parent;
     }
     unset($_originalNamespace, $_namespace);
 }
 /**
  * @param Market_OrderModel      $order
  * @param Market_LineItemModel[] $lineItems
  * @param Market_DiscountModel   $discount
  *
  * @return Market_OrderAdjustmentModel|false
  */
 private function getAdjustment(Market_OrderModel $order, array $lineItems, Market_DiscountModel $discount)
 {
     //preparing model
     $adjustment = new Market_OrderAdjustmentModel();
     $adjustment->type = self::ADJUSTMENT_TYPE;
     $adjustment->name = $discount->name;
     $adjustment->orderId = $order->id;
     $adjustment->description = $this->getDescription($discount);
     $adjustment->optionsJson = $discount->attributes;
     //checking items
     $matchingQty = 0;
     $matchingTotal = 0;
     foreach ($lineItems as $item) {
         if (\Craft\craft()->market_discount->matchLineItem($item, $discount)) {
             $matchingQty += $item->qty;
             $matchingTotal += $item->getSubtotalWithSale();
         }
     }
     if (!$matchingQty) {
         return false;
     }
     if ($matchingQty < $discount->purchaseQty) {
         return false;
     }
     if ($matchingTotal < $discount->purchaseTotal) {
         return false;
     }
     // calculate discount (adjustment amount should be negative)
     $amount = $discount->baseDiscount;
     $amount += $discount->perItemDiscount * $matchingQty;
     $amount += $discount->percentDiscount * $matchingTotal;
     foreach ($lineItems as $item) {
         $item->discount = $discount->perItemDiscount * $item->qty + $discount->percentDiscount * $item->getSubtotalWithSale();
         // If the discount is larger than the subtotal
         // make the discount equal the discount, thus making the item free.
         if ($item->discount * -1 > $item->getSubtotalWithSale()) {
             $item->discount = -$item->getSubtotalWithSale();
         }
         if (!$item->purchasable->product->promotable) {
             $item->discount = 0;
         }
         if ($discount->freeShipping) {
             $item->shippingCost = 0;
         }
     }
     if ($discount->freeShipping) {
         $order->baseShippingCost = 0;
     }
     $order->baseDiscount = $discount->baseDiscount;
     // only display adjustment if an amount was calculated
     if ($amount) {
         $adjustment->amount = $amount;
         return $adjustment;
     } else {
         return false;
     }
 }
Beispiel #13
0
 /**
  * Calls the specified hook, with the specified "source" text. Differs to
  * the standard Craft PluginsService::call method, in that the results are
  * cumulative. That is, FirstPlugin receives the source string,
  * SecondPlugin receives the source string after it has been parsed by
  * FirstPlugin, and so forth.
  *
  * There are clearly some potential downsides to this, as hook handlers
  * could find themselves competing to parse the string. However, that would
  * still be the case with the standard PluginsService::call method, it's
  * just the results would be a lot more difficult to process.
  *
  * @param $hook
  * @param $source
  *
  * @return mixed
  */
 private function callHook($hook, $source)
 {
     $result = $source;
     foreach (\Craft\craft()->plugins->getPlugins() as $plugin) {
         if (method_exists($plugin, $hook)) {
             $result = $plugin->{$hook}($source);
         }
     }
     return $result;
 }
Beispiel #14
0
 /**
  * (non-PHPdoc)
  * @see \mithra62\Platforms\Craft::getConfigOverrides()
  */
 public function getConfigOverrides()
 {
     $path = rtrim(\Craft\craft()->path->getConfigPath(), '/') . '/backuppro.php';
     if (file_exists($path)) {
         $config = (include $path);
         if (is_array($config)) {
             return $config;
         }
     }
     return array();
 }
 public function authenticate()
 {
     \Craft\Craft::log(__METHOD__, \Craft\LogLevel::Info, true);
     $socialUser = \Craft\craft()->social->getSocialUserById($this->socialUserId);
     if ($socialUser) {
         $this->_id = $socialUser->user->id;
         $this->username = $socialUser->user->username;
         $this->errorCode = static::ERROR_NONE;
         return true;
     } else {
         return false;
     }
 }
 private function handle(Request $request, Response $response)
 {
     $route = $request->getRoute();
     if ($route->is('GET', '/api/commerce/{me}')) {
         $customer = \Craft\craft()->commerce_customers->getCustomer();
         $response = $response->withItem($customer);
     }
     if ($route->is('GET', '/api/commerce/product')) {
         \Craft\Craft::dd($request->getCriteria());
         $products = \Craft\craft()->elements->getCriteria('Commerce_Product', $request->getCriteria())->find();
         $response = $response->withCollection($products);
     }
     return $response;
 }
 /**
  * This and two next are special functions which allow making nested
  * transactions
  */
 public static function beginStackedTransaction()
 {
     if (self::$transactionsStackSize == 0) {
         if (\Craft\craft()->db->getCurrentTransaction() === null) {
             self::$transaction = \Craft\craft()->db->beginTransaction();
         } else {
             // If we are at zero but 3rd party has a current transaction in play
             self::$transaction = \Craft\craft()->db->getCurrentTransaction();
             // By setting to 1, we will never commit, but whoever started it should.
             self::$transactionsStackSize = 1;
         }
     }
     ++self::$transactionsStackSize;
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     if (!array_key_exists("value", $context)) {
         // line 2
         $context["value"] = null;
     }
     // line 5
     $context["id"] = $this->getContext($context, "id") . "-date";
     // line 7
     if (array_key_exists("name", $context) && $this->getContext($context, "name")) {
         // line 8
         $context["name"] = $this->getContext($context, "name") . "[date]";
     }
     // line 11
     echo "<div class=\"datewrapper\">";
     // line 12
     $this->env->loadTemplate("_includes/forms/text")->display(array_merge($context, array("autocomplete" => false, "size" => 10, "value" => $this->getContext($context, "value") ? $this->getAttribute($this->getContext($context, "value"), "localeDate", array(), "method") : "")));
     // line 13
     echo "</div>";
     // line 15
     ob_start();
     // line 16
     echo "\n\tvar \$datePicker = \$('#";
     // line 17
     echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\craft()->templates->namespaceInputId($this->getContext($context, "id")), "js"), "html", null, true);
     echo "');\n\t\$datePicker.datepicker({\n\t\tconstrainInput: false,\n\t\tdateFormat: '";
     // line 20
     echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "i18n"), "datepickerJsFormat"), "html", null, true);
     echo "',\n\t\tdefaultDate: new Date(";
     // line 21
     if ($this->getContext($context, "value")) {
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "value"), "year"), "html", null, true);
         echo ", ";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "value"), "month") - 1, "html", null, true);
         echo ", ";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "value"), "day"), "html", null, true);
     }
     echo "),\n\t\tprevText:   '";
     // line 22
     echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\Craft::t("Prev"), "js"), "html", null, true);
     echo "',\n\t\tnextText:   '";
     // line 23
     echo twig_escape_filter($this->env, twig_escape_filter($this->env, \Craft\Craft::t("Next"), "js"), "html", null, true);
     echo "',\n\t});";
     $context["js"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 27
     \Craft\craft()->templates->includeJs($this->getContext($context, "js"));
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 2
     $context["forms"] = $this->env->loadTemplate("_includes/forms");
     // line 3
     $context["title"] = \Craft\Craft::t("Login");
     // line 4
     \Craft\craft()->templates->includeCssResource("css/login.css");
     // line 5
     \Craft\craft()->templates->includeJsResource("js/login.js");
     // line 6
     \Craft\craft()->templates->includeTranslations("Reset Password", "Check your email for instructions to reset your password.");
     // line 11
     $context["username"] = $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "config"), "rememberUsernameDuration") ? $this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "session"), "rememberedUsername") : "";
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 /**
  * @param Market_OrderModel      $order
  * @param Market_LineItemModel[] $lineItems
  *
  * @return \Craft\Market_OrderAdjustmentModel[]
  */
 public function adjust(Market_OrderModel &$order, array $lineItems = [])
 {
     $shippingAddress = \Craft\craft()->market_address->getAddressById($order->shippingAddressId);
     if (!$shippingAddress->id) {
         $shippingAddress = null;
     }
     $adjustments = [];
     $taxRates = \Craft\craft()->market_taxRate->getAll(['with' => ['taxZone', 'taxZone.countries', 'taxZone.states.country']]);
     /** @var Market_TaxRateModel $rate */
     foreach ($taxRates as $rate) {
         if ($adjustment = $this->getAdjustment($order, $lineItems, $shippingAddress, $rate)) {
             $adjustments[] = $adjustment;
         }
     }
     return $adjustments;
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     try {
         $this->router = \Craft\craft()->urlManager;
         $this->dispatcher = new Dispatcher($this->router);
         $this->request = new Request();
         $this->response = new Response($this->request);
     } catch (RestfulApiException $exception) {
         $response = new Response();
         $response->setStatus($exception->getStatusCode(), $exception->getStatusPhrase())->setError($exception)->send();
     } catch (\Craft\Exception $craftException) {
         $exception = new RestfulApiException();
         $exception->setMessage($craftException->getMessage());
         $response = new Response();
         return $response->setError($exception)->send();
     }
 }
 public function seed()
 {
     $states = ['AU' => ['ACT' => 'Australian Capital Territory', 'NSW' => 'New South Wales', 'NT' => 'Northern Territory', 'QLD' => 'Queensland', 'SA' => 'South Australia', 'TAS' => 'Tasmania', 'VIC' => 'Victoria', 'WA' => 'Western Australia'], 'CA' => ['AB' => 'Alberta', 'BC' => 'British Columbia', 'MB' => 'Manitoba', 'NB' => 'New Brunswick', 'NL' => 'Newfoundland and Labrador', 'NT' => 'Northwest Territories', 'NS' => 'Nova Scotia', 'NU' => 'Nunavut', 'ON' => 'Ontario', 'PE' => 'Prince Edward Island', 'QC' => 'Quebec', 'SK' => 'Saskatchewan', 'YT' => 'Yukon'], 'US' => ['AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'DC' => 'District of Columbia', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming']];
     $criteria = new \CDbCriteria();
     $criteria->addInCondition('iso', array_keys($states));
     $countries = Market_CountryRecord::model()->findAll($criteria);
     $code2id = [];
     foreach ($countries as $record) {
         $code2id[$record->iso] = $record->id;
     }
     $rows = [];
     foreach ($states as $iso => $list) {
         foreach ($list as $abbr => $name) {
             $rows[] = [$code2id[$iso], $abbr, $name];
         }
     }
     $table = Market_StateRecord::model()->getTableName();
     \Craft\craft()->db->createCommand()->insertAll($table, ['countryId', 'abbreviation', 'name'], $rows);
 }
 /**
  * @param Market_OrderModel      $order
  * @param Market_LineItemModel[] $lineItems
  *
  * @return \Craft\Market_OrderAdjustmentModel[]
  */
 public function adjust(Market_OrderModel &$order, array $lineItems = [])
 {
     $shippingMethod = \Craft\craft()->market_shippingMethod->getById($order->shippingMethodId);
     if (!$shippingMethod->id) {
         return [];
     }
     $adjustments = [];
     if ($rule = \Craft\craft()->market_shippingMethod->getMatchingRule($order, $shippingMethod)) {
         //preparing model
         $adjustment = new Market_OrderAdjustmentModel();
         $adjustment->type = self::ADJUSTMENT_TYPE;
         $adjustment->name = $shippingMethod->name;
         $adjustment->description = $this->getDescription($rule);
         $adjustment->orderId = $order->id;
         $adjustment->optionsJson = $rule->attributes;
         //checking items tax categories
         $weight = $qty = $price = 0;
         $itemShippingTotal = 0;
         foreach ($lineItems as $item) {
             $weight += $item->qty * $item->weight;
             $qty += $item->qty;
             $price += $item->getSubtotalWithSale();
             $item->shippingCost = $item->getSubtotalWithSale() * $rule->percentageRate + $rule->perItemRate + $item->weight * $rule->weightRate;
             $itemShippingTotal += $item->shippingCost * $item->qty;
             if ($item->purchasable->product->freeShipping) {
                 $item->shippingCost = 0;
             }
         }
         //amount for displaying in adjustment
         $amount = $rule->baseRate + $itemShippingTotal;
         $amount = max($amount, $rule->minRate * 1);
         if ($rule->maxRate * 1) {
             $amount = min($amount, $rule->maxRate * 1);
         }
         $adjustment->amount = $amount;
         //real shipping base rate (can be a bit artificial because it counts min and max rate as well, but in general it equals to baseRate)
         $order->baseShippingCost = $amount - $itemShippingTotal;
         $adjustments[] = $adjustment;
     }
     return $adjustments;
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 1
     \Craft\craft()->templates->includeCssResource("css/craft.css", true);
     // line 3
     echo "<!DOCTYPE html>\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en-US\">\n<head>\n\t";
     // line 6
     $this->displayBlock('head', $context, $blocks);
     // line 17
     echo "</head>\n<body class=\"";
     // line 18
     echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute($this->getAttribute($this->getContext($context, "craft"), "i18n"), "getLocaleData", array(), "method"), "getOrientation", array(), "method"), "html", null, true);
     echo "\">\n\t";
     // line 19
     $this->displayBlock('body', $context, $blocks);
     // line 20
     echo "\t";
     $this->displayBlock('foot', $context, $blocks);
     // line 21
     echo "</body>\n</html>\n";
 }
Beispiel #25
0
 public function api($method = 'get', $uri, $params = null, $headers = null, $postFields = null)
 {
     // client
     $client = new Client('https://api.twitter.com/1.1');
     $provider = \Craft\craft()->oauth->getProvider('twitter');
     $token = $this->token;
     $oauthData = array('consumer_key' => $provider->provider->clientId, 'consumer_secret' => $provider->provider->clientSecret, 'token' => $token->accessToken, 'token_secret' => $token->secret);
     $oauth = new \Guzzle\Plugin\Oauth\OauthPlugin($oauthData);
     $client->addSubscriber($oauth);
     // request
     $format = 'json';
     $query = '';
     if ($params) {
         $query = http_build_query($params);
         if ($query) {
             $query = '?' . $query;
         }
     }
     $url = $uri . '.' . $format . $query;
     $response = $client->get($url, $headers, $postFields)->send();
     $response = $response->json();
     return $response;
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 3
     $context["entryTypes"] = $this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method");
     // line 4
     $context["multiple"] = twig_length_filter($this->env, $this->getContext($context, "entryTypes")) > 1;
     // line 6
     ob_start();
     // line 7
     echo "\t<table id=\"entrytypes\" class=\"data fullwidth collapsible\">\n\t\t<thead>\n\t\t\t<th scope=\"col\">";
     // line 9
     echo twig_escape_filter($this->env, \Craft\Craft::t("Name"), "html", null, true);
     echo "</th>\n\t\t\t<th scope=\"col\">";
     // line 10
     echo twig_escape_filter($this->env, \Craft\Craft::t("Handle"), "html", null, true);
     echo "</th>\n\t\t\t";
     // line 11
     if ($this->getContext($context, "multiple")) {
         // line 12
         echo "\t\t\t\t<td class=\"thin\"></td>\n\t\t\t\t<td class=\"thin\"></td>\n\t\t\t";
     }
     // line 15
     echo "\t\t</thead>\n\t\t<tbody>\n\t\t\t";
     // line 17
     $context['_parent'] = (array) $context;
     $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method"));
     foreach ($context['_seq'] as $context["_key"] => $context["entryType"]) {
         // line 18
         echo "\t\t\t\t<tr data-id=\"";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "id"), "html", null, true);
         echo "\" data-name=\"";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "name"), "html", null, true);
         echo "\">\n\t\t\t\t\t<th scope=\"row\" data-title=\"";
         // line 19
         echo twig_escape_filter($this->env, \Craft\Craft::t("Name"), "html", null, true);
         echo "\"><a href=\"";
         echo twig_escape_filter($this->env, \Craft\UrlHelper::getUrl("settings/sections/" . $this->getAttribute($this->getContext($context, "section"), "id") . "/entrytypes/" . $this->getAttribute($this->getContext($context, "entryType"), "id")), "html", null, true);
         echo "\">";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "name"), "html", null, true);
         echo "</a></th>\n\t\t\t\t\t<td data-title=\"";
         // line 20
         echo twig_escape_filter($this->env, \Craft\Craft::t("Handle"), "html", null, true);
         echo "\"><code>";
         echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "handle"), "html", null, true);
         echo "</code></td>\n\t\t\t\t\t";
         // line 21
         if ($this->getContext($context, "multiple")) {
             // line 22
             echo "\t\t\t\t\t\t<td class=\"thin\"><a class=\"move icon\" title=\"";
             echo twig_escape_filter($this->env, \Craft\Craft::t("Reorder"), "html", null, true);
             echo "\" role=\"button\"></a></td>\n\t\t\t\t\t\t<td class=\"thin\"><a class=\"delete icon\" title=\"";
             // line 23
             echo twig_escape_filter($this->env, \Craft\Craft::t("Delete"), "html", null, true);
             echo "\" role=\"button\"></a></td>\n\t\t\t\t\t";
         }
         // line 25
         echo "\t\t\t\t</tr>\n\t\t\t";
     }
     $_parent = $context['_parent'];
     unset($context['_seq'], $context['_iterated'], $context['_key'], $context['entryType'], $context['_parent'], $context['loop']);
     $context = array_intersect_key($context, $_parent) + $_parent;
     // line 27
     echo "\t\t</tbody>\n\t</table>\n\n\t";
     // line 30
     if ($this->getAttribute($this->getContext($context, "section"), "type") != "single") {
         // line 31
         echo "\t\t<div class=\"buttons\">\n\t\t\t<a href=\"";
         // line 32
         echo twig_escape_filter($this->env, \Craft\UrlHelper::getUrl("settings/sections/" . $this->getAttribute($this->getContext($context, "section"), "id") . "/entrytypes/new"), "html", null, true);
         echo "\" class=\"btn submit add icon\">";
         echo twig_escape_filter($this->env, \Craft\Craft::t("New Entry Type"), "html", null, true);
         echo "</a>\n\t\t</div>\n\t";
     }
     $context["content"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 38
     if ($this->getAttribute($this->getContext($context, "section"), "type") != "single") {
         // line 39
         ob_start();
         // line 40
         echo "\t\tnew Craft.AdminTable({\n\t\t\ttableSelector: '#entrytypes',\n\t\t\tdeleteAction: 'sections/deleteEntryType',\n\t\t\tminObjects: 1,\n\t\t\tsortable: true,\n\t\t\treorderAction: 'sections/reorderEntryTypes',\n\t\t\tconfirmDeleteMessage: '";
         // line 46
         echo twig_escape_filter($this->env, \Craft\Craft::t("Are you sure you want to delete “{name}” and all entries that use it?"), "html", null, true);
         echo "',\n\t\t});\n\t";
         $context["js"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
         // line 49
         \Craft\craft()->templates->includeJs($this->getContext($context, "js"));
     }
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
 protected function doDisplay(array $context, array $blocks = array())
 {
     // line 2
     $context["title"] = \Craft\Craft::t("Sections");
     // line 4
     $context["crumbs"] = array(0 => array("label" => \Craft\Craft::t("Settings"), "url" => \Craft\UrlHelper::getUrl("settings")));
     // line 8
     $context["docsUrl"] = "http://buildwithcraft.com/docs/sections-and-entries#sections";
     // line 11
     ob_start();
     // line 12
     echo "\t<div id=\"nosections\"";
     if ($this->getContext($context, "sections")) {
         echo " class=\"hidden\"";
     }
     echo ">\n\t\t<p>";
     // line 13
     echo twig_escape_filter($this->env, \Craft\Craft::t("No sections exist yet."), "html", null, true);
     echo "</p>\n\t</div>\n\n\t";
     // line 16
     if (twig_length_filter($this->env, $this->getContext($context, "sections"))) {
         // line 17
         echo "\t\t<table id=\"sections\" class=\"data fullwidth collapsible\">\n\t\t\t<thead>\n\t\t\t\t<th scope=\"col\">";
         // line 19
         echo twig_escape_filter($this->env, \Craft\Craft::t("Name"), "html", null, true);
         echo "</th>\n\t\t\t\t<th scope=\"col\">";
         // line 20
         echo twig_escape_filter($this->env, \Craft\Craft::t("Handle"), "html", null, true);
         echo "</th>\n\t\t\t\t<th scope=\"col\">";
         // line 21
         echo twig_escape_filter($this->env, \Craft\Craft::t("Type"), "html", null, true);
         echo "</th>\n\t\t\t\t<th scope=\"col\">";
         // line 22
         echo twig_escape_filter($this->env, \Craft\Craft::t("URL Format"), "html", null, true);
         echo "</th>\n\t\t\t\t<th scope=\"col\">";
         // line 23
         echo twig_escape_filter($this->env, \Craft\Craft::t("Entry Types"), "html", null, true);
         echo "</th>\n\t\t\t\t<td class=\"thin\"></td>\n\t\t\t</thead>\n\t\t\t<tbody>\n\t\t\t\t";
         // line 27
         $context['_parent'] = (array) $context;
         $context['_seq'] = twig_ensure_traversable($this->getContext($context, "sections"));
         foreach ($context['_seq'] as $context["_key"] => $context["section"]) {
             // line 28
             echo "\t\t\t\t\t<tr data-id=\"";
             echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "id"), "html", null, true);
             echo "\" data-name=\"";
             echo twig_escape_filter($this->env, \Craft\Craft::t($this->getAttribute($this->getContext($context, "section"), "name")), "html", null, true);
             echo "\">\n\t\t\t\t\t\t<th scope=\"row\" data-title=\"";
             // line 29
             echo twig_escape_filter($this->env, \Craft\Craft::t("Name"), "html", null, true);
             echo "\"><a href=\"";
             echo twig_escape_filter($this->env, \Craft\UrlHelper::getUrl("settings/sections/" . $this->getAttribute($this->getContext($context, "section"), "id")), "html", null, true);
             echo "\">";
             echo twig_escape_filter($this->env, \Craft\Craft::t($this->getAttribute($this->getContext($context, "section"), "name")), "html", null, true);
             echo "</a></th>\n\t\t\t\t\t\t<td data-title=\"";
             // line 30
             echo twig_escape_filter($this->env, \Craft\Craft::t("Handle"), "html", null, true);
             echo "\"><code>";
             echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "handle"), "html", null, true);
             echo "</code></td>\n\t\t\t\t\t\t<td data-title=\"";
             // line 31
             echo twig_escape_filter($this->env, \Craft\Craft::t("Type"), "html", null, true);
             echo "\">";
             echo twig_escape_filter($this->env, \Craft\Craft::t(twig_title_string_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "type"))), "html", null, true);
             echo "</td>\n\t\t\t\t\t\t<td data-title=\"";
             // line 32
             echo twig_escape_filter($this->env, \Craft\Craft::t("URL Format"), "html", null, true);
             echo "\" dir=\"ltr\">";
             // line 33
             if ($this->getAttribute($this->getContext($context, "section"), "isHomepage", array(), "method")) {
                 // line 34
                 echo "<div data-icon=\"home\" title=\"";
                 echo twig_escape_filter($this->env, \Craft\Craft::t("Homepage"), "html", null, true);
                 echo "\"></div>";
             } else {
                 // line 36
                 echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "getUrlFormat", array(), "method"), "html", null, true);
             }
             // line 38
             echo "</td>\n\t\t\t\t\t\t<td data-title=\"";
             // line 39
             echo twig_escape_filter($this->env, \Craft\Craft::t("Entry Types"), "html", null, true);
             echo "\">\n\t\t\t\t\t\t\t";
             // line 40
             if ($this->getAttribute($this->getContext($context, "section"), "type") == "single" && twig_length_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method")) == 1) {
                 // line 41
                 echo "\t\t\t\t\t\t\t\t";
                 $context["entryType"] = $this->getAttribute($this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method"), 0, array(), "array");
                 // line 42
                 echo "\t\t\t\t\t\t\t\t<a href=\"";
                 echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "getCpEditUrl", array(), "method"), "html", null, true);
                 echo "\">";
                 echo twig_escape_filter($this->env, \Craft\Craft::t("Edit entry type"), "html", null, true);
                 echo "</a>\n\t\t\t\t\t\t\t";
             } else {
                 // line 44
                 echo "\t\t\t\t\t\t\t\t<a href=\"";
                 echo twig_escape_filter($this->env, \Craft\UrlHelper::getUrl("settings/sections/" . $this->getAttribute($this->getContext($context, "section"), "id") . "/entrytypes"), "html", null, true);
                 echo "\">";
                 echo twig_escape_filter($this->env, \Craft\Craft::t("Edit entry types ({count})", array("count" => twig_length_filter($this->env, $this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method")))), "html", null, true);
                 echo "</a>\n\t\t\t\t\t\t\t\t<a class=\"menubtn\" title=\"";
                 // line 45
                 echo twig_escape_filter($this->env, \Craft\Craft::t("Entry Types"), "html", null, true);
                 echo "\"></a>\n\t\t\t\t\t\t\t\t<div class=\"menu\">\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t";
                 // line 48
                 $context['_parent'] = (array) $context;
                 $context['_seq'] = twig_ensure_traversable($this->getAttribute($this->getContext($context, "section"), "getEntryTypes", array(), "method"));
                 foreach ($context['_seq'] as $context["_key"] => $context["entryType"]) {
                     // line 49
                     echo "\t\t\t\t\t\t\t\t\t\t\t<li><a href=\"";
                     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "getCpEditUrl", array(), "method"), "html", null, true);
                     echo "\">";
                     echo twig_escape_filter($this->env, $this->getAttribute($this->getContext($context, "entryType"), "name"), "html", null, true);
                     echo "</a></li>\n\t\t\t\t\t\t\t\t\t\t";
                 }
                 $_parent = $context['_parent'];
                 unset($context['_seq'], $context['_iterated'], $context['_key'], $context['entryType'], $context['_parent'], $context['loop']);
                 $context = array_intersect_key($context, $_parent) + $_parent;
                 // line 51
                 echo "\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t";
             }
             // line 54
             echo "\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td class=\"thin\"><a class=\"delete icon\" title=\"";
             // line 55
             echo twig_escape_filter($this->env, \Craft\Craft::t("Delete"), "html", null, true);
             echo "\" role=\"button\"></a></td>\n\t\t\t\t\t</tr>\n\t\t\t\t";
         }
         $_parent = $context['_parent'];
         unset($context['_seq'], $context['_iterated'], $context['_key'], $context['section'], $context['_parent'], $context['loop']);
         $context = array_intersect_key($context, $_parent) + $_parent;
         // line 58
         echo "\t\t\t</tbody>\n\t\t</table>\n\t";
     }
     // line 61
     echo "\n\t<div id=\"newsectioncontainer\" class=\"buttons";
     // line 62
     if ($this->getContext($context, "CraftEdition") == $this->getContext($context, "CraftPersonal") && twig_length_filter($this->env, $this->getContext($context, "sections")) >= $this->getContext($context, "maxSections")) {
         echo " hidden";
     }
     echo "\">\n\t\t<a href=\"";
     // line 63
     echo twig_escape_filter($this->env, \Craft\UrlHelper::getUrl("settings/sections/new"), "html", null, true);
     echo "\" class=\"btn submit add icon\">";
     echo twig_escape_filter($this->env, \Craft\Craft::t("New Section"), "html", null, true);
     echo "</a>\n\t</div>\n";
     $context["content"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 68
     ob_start();
     // line 69
     echo "\tvar adminTable = new Craft.AdminTable({\n\t\ttableSelector: '#sections',\n\t\tnoObjectsSelector: '#nosections',\n\t\tnewObjectBtnSelector: '#newsectioncontainer',\n\t\tdeleteAction: 'sections/deleteSection',\n\t\tconfirmDeleteMessage: '";
     // line 74
     echo twig_escape_filter($this->env, \Craft\Craft::t("Are you sure you want to delete “{name}” and all its entries?"), "html", null, true);
     echo "',\n\t\t";
     // line 75
     if ($this->getContext($context, "CraftEdition") == $this->getContext($context, "CraftPersonal")) {
         echo "maxObjects: ";
         echo twig_escape_filter($this->env, $this->getContext($context, "maxSections"), "html", null, true);
         echo ",";
     }
     // line 76
     echo "\t\tonDeleteObject: function()\n\t\t{\n\t\t\t// Hide the Entries tab if that was the last one\n\t\t\tif (adminTable.totalObjects == 0)\n\t\t\t{\n\t\t\t\t\$('#nav-entries').remove();\n\t\t\t}\n\t\t}\n\t});\n";
     $context["js"] = '' === ($tmp = ob_get_clean()) ? '' : new Twig_Markup($tmp, $this->env->getCharset());
     // line 86
     \Craft\craft()->templates->includeJs($this->getContext($context, "js"));
     $this->parent->display($context, array_merge($this->blocks, $blocks));
 }
Beispiel #28
0
 /**
  * Set Default Criteria
  *
  * @return ElementCriteriaModel Criteria
  */
 protected function setDefaultCriteria()
 {
     $element_type = $this->getAttribute('elementType');
     $element_id = $this->getAttribute('elementId');
     $pagination_parameter = \Craft\craft()->config->get('paginationParameter', 'restfulApi');
     if ($element_type) {
         $params = $this->getQueryParams();
         $criteria = \Craft\craft()->elements->getCriteria($element_type, $params);
         if (isset($criteria->{$pagination_parameter})) {
             $criteria->offset = ($criteria->{$pagination_parameter} - 1) * $criteria->limit;
             unset($criteria->{$pagination_parameter});
         }
         if ($element_id) {
             $criteria->archived = null;
             $criteria->fixedOrder = null;
             $criteria->limit = 1;
             $criteria->localeEnabled = false;
             $criteria->offset = 0;
             $criteria->order = null;
             $criteria->status = null;
             $criteria->editable = null;
             if (is_numeric($element_id)) {
                 $criteria->id = $element_id;
             } else {
                 $criteria->slug = $element_id;
             }
         }
         $this->criteria = $criteria;
     }
 }
Beispiel #29
0
<?php

return ['devMode' => \Craft\craft()->config->get('devMode'), 'apiRoutePrefix' => 'api', 'defaultHeaders' => ['Pragma' => ['no-cache'], 'Cache-Control' => ['no-store', 'no-cache', 'must-revalidate', 'post-check=0', 'pre-check=0'], 'Content-Type' => ['application/json; charset=utf-8']], 'paginationParameter' => 'page', 'paginationBaseUrl' => \Craft\craft()->request->getPath(), 'contentModelFieldsLocation' => 'fields', 'contentRecursionLimit' => 2, 'defaultAuth' => null, 'auth' => ['basicAuth' => ['username' => '', 'password' => ''], 'craft' => ['permissions' => [], 'users' => [], 'groups' => []]], 'autoload' => ['transformers' => true, 'validators' => true], 'defaultSerializer' => 'ArraySerializer', 'serializers' => ['ArraySerializer' => 'League\\Fractal\\Serializer\\ArraySerializer', 'DataArraySerializer' => 'League\\Fractal\\Serializer\\DataArraySerializer', 'JsonApiSerializer' => 'League\\Fractal\\Serializer\\JsonApiSerializer'], 'exceptionTransformer' => 'RestfulApi\\Transformers\\ArrayTransformer', 'elementTypes' => ['*' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\ArrayTransformer', 'validator' => null, 'permissions' => ['public' => ['GET'], 'authenticated' => ['POST', 'PUT', 'PATCH']]], 'Asset' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\AssetFileTransformer', 'validator' => 'RestfulApi\\Validators\\AssetFileValidator'], 'Category' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\CategoryTransformer', 'validator' => 'RestfulApi\\Validators\\CategoryValidator'], 'Entry' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\EntryTransformer', 'validator' => 'RestfulApi\\Validators\\EntryValidator'], 'GlobalSet' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\GlobalSetTransformer', 'validator' => 'RestfulApi\\Validators\\GlobalSetValidator'], 'MatrixBlock' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\MatrixBlockTransformer', 'validator' => 'RestfulApi\\Validators\\MatrixBlockValidator'], 'Tag' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\TagTransformer', 'validator' => 'RestfulApi\\Validators\\TagValidator'], 'User' => ['enabled' => true, 'transformer' => 'RestfulApi\\Transformers\\UserTransformer', 'validator' => 'RestfulApi\\Validators\\UserValidator']]];
 public function hasScope($scope)
 {
     return \Craft\craft()->oauth->scopeIsEnough($scope, $this->scope);
 }