@since  1.0

{@inheritDoc}
337590
public function fetch( $id ) {

		reset( $this->caches );

		foreach ( $this->caches as $key => $cache ) {

			if ( !$cache->contains( $id ) ) {
				continue;
			}

			$data = $cache->fetch( $id );

			// The data were not available in a previous instance and it is assumed
			// that a preceding cache is faster (in-memory lookup etc.) than the
			// current instance therefore the content is stored one level up for
			// the next lookup
			if ( $key > 0 ) {
				$this->caches[ $key - 1 ]->save( $id, $data );
			}

			return $data;
		}

		return false;
	}
1348885
public static function bind($key, $object = null)
    {
        if(is_array($key))
        {
            foreach($key as $key => $object)
            {
                self::$bindings[$key] = $object;
            }
        }
        else
        {
            self::$bindings[$key] = $object;
        }
    }
105636
static function simple()
    {
        $xml = self::maker(false, false, false, false, false);
        \Moxl\API::request($xml);
    }
720248
public function init(Document $document)
	{
		$this->hashId = $this->getHashId($document, $this->serviceLocator);
		$this->title = $document->getTitle();
		$this->price = $this->getPrice($document);
		$this->priceFormatted = $this->getPriceFormatted($document);
		$this->meta = $this->getMeta($document);
		$this->date = $this->getDateFormatted($document);
		$this->image = $this->getImage($document, $this->serviceLocator); // rimuovere
		$this->images = $this->getImages($document, $this->serviceLocator); 
		$this->content = $document->getContent();
		$this->nl2brContent = nl2br($document->getContent());
		$this->dateInsert = $document->getDateInsert()->format('Y/m/d H:i:s');
		$this->visited = $document->getVisited();

		$this->state = $document->getState();
		$this->stateFormatted = $this->getStateFormatted($document);
		
		$state = $document->getState();
		$this->isActive = Document::DOCUMENT_STATE_ACTIVE == $state;
		$this->isDeactive = Document::DOCUMENT_STATE_DEACTIVE == $state;
		$this->isDeleted = Document::DOCUMENT_STATE_DELETED == $state;
		$this->isExpired = $this->getIsExpired($document);
		$this->cssClass = $this->isActive && !$this->isExpired ? '' : 'warning';
		$this->purpose = $this->getPurpose($document); 
		$this->mobile = $this->getMobile($document); 
		$this->hidemobile = $this->getHideMobile($document); 

		$this->location = $this->getLocation($document, $this->serviceLocator);
		$this->locationFormatted = $this->getLocationFormatted($document, $this->serviceLocator); 
		
		$this->categories = $this->getCategories($document); 
		$this->category = $this->getCategory($document); 
		$this->slug = $this->getSlug($document); 
		$this->address = $this->getAddress($document, $this->serviceLocator);
		$this->editaddress = $this->getEditAddress($document);
		$this->insert = $this->getInsertDate($document);
		
		// Some user data
		$user = $document->getUser();
		$this->userId = $this->getUserHashId($document, $this->serviceLocator);
		$this->fullname = $user->getName() . ' ' . $user->getSurname();
		
		// Some location data
		$geoname = $document->getGeoname();
		$this->longitude = null !== $geoname ? $geoname->getLongitude() : null;
		$this->latitude = null !== $geoname ? $geoname->getLatitude() : null;
		
		$this->breadcrumbs = $this->getBreadcrumbs($document);
		
		return $this;
	}
642714
public function delete($id)
    {
        $this->beforeDelete($id);
        $this->entity->delete($id);
        $this->afterDelete($id);
    }
54593
public function resolve()
    {
        $this->template = $this->createTemplate($this->templateClass);
        $this->template->setZones($this->zones);

        $this->assertEntityIsValid($this->template, array('Template', 'creation'));

        $this->eventDispatcher->addListener(
            TemplateEvents::TEMPLATE_CREATED,
            $handler = array($this, 'onTemplateCreated')
        );
        $this->fireEvent(
            TemplateEvents::TEMPLATE_CREATED,
            new TemplateEvent($this->template, $this)
        );
        $this->eventDispatcher->removeListener(TemplateEvents::TEMPLATE_CREATED, $handler);

        return $this->template;
    }
277297
public function deleteAction($id)
    {
        /** @var Menus_Entity_Table_Menu $table */
        $table = ORM::getTable($this->plugin, 'Menu');
        /** @var Menus_Entity_Menu $menu */
        $menu = $table->find($id);

        if (!is_null($menu))
        {
            $table->delete($menu);
        }
        HTTP::redirect(str_replace('&amp;', '&', $this->ui->url()));
    }
926723
public function sync()
    {
        $this->connection()->transaction(function () {
            foreach ($this->editable() as $field) {
                // get original HTML input
                $field = $field->getInput();

                $name = $field->getName();

                if ($this->isKey($field) || $this->isTranslatable($field) || $this->isMediaFile($field)) {
                    continue;
                }

                $this->collectRelations($field, $name);

                $value = $this->isFile($field) ? $this->request->file($name) : $this->request->get($name);

                $value = $this->isBoolean($field) ? (bool) $value : $value;

                $value = $this->handleJsonType($name, $value);

                $this->data[$name] = $value;
            }

            $this->cleanData();

            $this->collectTranslatable();

            $this->appendTranslationsToRelations();

            Model::unguard();

            /*
            |-------------------------------------------------------
            | Save main data
            |-------------------------------------------------------
            */
            $this->save();

            /*
            |-------------------------------------------------------
            | Relationships
            |-------------------------------------------------------
            | Save related data, fetched by "relation" from related tables
            */
            $this->saveRelations();

            $this->saveMedia();

            Model::reguard();
        });

        return $this->repository;
    }
295586
static function subscribed($to)
    {
        $xml = self::maker($to, false, false, false, 'subscribed');
        \Moxl\API::request($xml);
    }
638908
protected function execute()
    {
        $result = false;

        $service = $this->getSubmittedValue('service');
        $source = $this->submittedSource;
        switch ($service) {
            case 'invoice_add':
                $forceSend = (bool) $this->getSubmittedValue('value');
                $result = $this->invoiceManager->send1($source, $forceSend);
                break;

            case 'invoice_paymentstatus_set':
                $localEntryInfo = $this->acumulusEntryManager->getByInvoiceSource($source);
                if ($localEntryInfo) {
                    if ((int) $this->getSubmittedValue('value') === Api::PaymentStatus_Paid) {
                        $paymentStatus = Api::PaymentStatus_Paid;
                        $dateFieldName = $this->getIdPrefix($this->submittedSource) . 'payment_date';
                        $paymentDate = $this->submittedValues[$dateFieldName];
                    } else {
                        $paymentStatus = Api::PaymentStatus_Due;
                        $paymentDate = '';
                    }
                    $result = $this->service->setPaymentStatus($localEntryInfo->getToken(), $paymentStatus, $paymentDate);
                } else {
                    $this->addErrorMessages(sprintf($this->t('unknown_entry'),
                        strtolower($this->t($this->submittedSource->getType())),
                        $this->submittedSource->getId()
                    ));
                }
                break;

            case 'entry_deletestatus_set':
                $localEntryInfo = $this->acumulusEntryManager->getByInvoiceSource($source);
                if ($localEntryInfo) {
                    $deleteStatus = $this->getSubmittedValue('value') === Api::Entry_Delete ? Api::Entry_Delete : Api::Entry_UnDelete;
                    $result = $this->service->setDeleteStatus($localEntryInfo->getEntryId(), $deleteStatus);
                } else {
                    $this->addErrorMessages(sprintf($this->t('unknown_entry'),
                    strtolower($this->t($this->submittedSource->getType())),
                        $this->submittedSource->getId()
                    ));
                }
                break;

            default:
                $this->addErrorMessages(sprintf($this->t('unknown_action'), $service));
                break;
        }

        return $result;
    }
1240529
public static function clean(&$what)
    {
        foreach ($what as $key => $value) {
            if (is_object($value)) {
                $what[$key] = 'OBJECT';
            }
            if (is_array($value)) {
                self::clean($value);
            }
        }
    }
906555
public function offset( $offset ) {
		$this->offset = $offset;
		if ( false === starts_with( $offset . '', ':' ) ) {
			$this->offset = (int) $offset;
		}
	}
432831
public function hasChanged($fields)
    {
        if ($this->_snapshot === false) {
            throw new PreconditionException(['getChangedFields failed: `:model` instance is snapshot disabled', 'model' => static::class]);
        }

        /** @noinspection ForeachSourceInspection */
        foreach ((array)$fields as $field) {
            if (!isset($this->_snapshot[$field]) || $this->{$field} !== $this->_snapshot[$field]) {
                return true;
            }
        }

        return false;
    }
1161612
public function hasChange()
    {
        return !is_null($this->resource) && ($this->resource->hasFields() || $this->resource->hasIndexes());
    }
342246
public function Bind()
	{
		if ( $this->getCount() > 0)
		{
			if ( $this->getAbstractNode(0) instanceof PathExprNode )
			{
				/**
				 * @var PathExprNode $pathExpr
				 */
				$pathExpr = $this->getAbstractNode(0);
				if ( in_array( $this->_name, FuncNode::$s_aggregates ) && $this->_ns == XmlReservedNs::xQueryFunc )
				{
					$pathExpr->Unordered = true;
				}
			}
		}
		parent::Bind();
	}
257926
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        /** @var PaymentInterface $payment */
        $payment = $request->getSource();

        $model = ArrayObject::ensureArrayObject($payment->getDetails());

        if (false == $model['reference']) {
            $model['reference'] = $payment->getNumber();
        }
        if (false == $model['amount']) {
            $this->gateway->execute($currency = new GetCurrency($payment->getCurrencyCode()));
            $amount = (string)$payment->getTotalAmount();

            if (0 < $currency->exp) {
                $divisor = pow(10, $currency->exp);

                $amount = (string)round($amount / $divisor, $currency->exp);
                if (false !== $pos = strpos($amount, '.')) {
                    $amount = str_pad($amount, $pos + 1 + $currency->exp, '0', STR_PAD_RIGHT);
                }
            }

            $model['amount'] = $amount;
            $model['currency'] = (string)strtoupper($currency->code);
        }
        if (false == $model['email']) {
            $model['email'] = $payment->getClientEmail();
        }
        if (false == $model['comment']) {
            $model['comment'] = 'Customer: ' . $payment->getClientId();
        }

        $request->setResult((array)$model);
    }
1203353
public function setMethod( $method )
	{
		if ( $method == $this->getMethod() ) { return; }

		$this->_values['method'] = (string) $method;
		$this->setModified();
	}