@since 2.0

{@inheritDoc}
973759
public function create( $serviceName ) {

		if ( is_string( $serviceName ) && isset( $this->aliases[$serviceName] ) ) {
			$serviceName = $this->aliases[$serviceName];
		}

		return $this->getReturnValueFromCallbackHandlerFor( $serviceName, func_get_args() );
	}
432009
public function execute()
    {
        $db = $this->dbHandle;
        $db->/** @scrutinizer ignore-call */
        sqliteCreateFunction('log', 'log', 1);
        $sql = '
		INSERT INTO inverse_document_frequency (term, inverseDocumentFrequency)
		SELECT DISTINCT term, (1+(log(:documentCount / COUNT(documentPath) + 1))) AS inverseDocumentFrequency
					  FROM term_count
				  GROUP BY term
		';

        if (!$stmt = $db->prepare($sql)) {
            $errorInfo = $db->errorInfo();
            $errorMsg = $errorInfo[2];
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
        }
        $stmt->bindValue(':documentCount', $this->documentCount);
        $result = $stmt->execute();
        if ($result === false) {
            $errorInfo = $db->errorInfo();
            $errorMsg = $errorInfo[2];
            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
        }
    }
1262835
public function init()
    {
        parent::init();

        self::$plugin = $this;

        if (!Craft::$app->getRequest()->getIsCpRequest()) {
            return;
        }

        // Register Components (Services)
        $this->setComponents([
            'singlesList' => SinglesList::class,
        ]);

        // Modified the entry index sources
        Event::on(Entry::class, Element::EVENT_REGISTER_SOURCES, function(RegisterElementSourcesEvent $event) {
            
            // Have we enabled the plugin?
            if ($this->getSettings()->expandSingles) {

                // Are there any Singles at all?
                foreach ($event->sources as $source) {
                    if (array_key_exists('key', $source) && $source['key'] === 'singles') {
                        $this->singlesList->createSinglesList($event);
                    }
                }
            }
        });

        // Hook onto a special hook from Redactor - it handles singles a little differently!
        if (class_exists(RedactorField::class)) {
            Event::on(RedactorField::class, RedactorField::EVENT_REGISTER_LINK_OPTIONS, function(RegisterLinkOptionsEvent $event) {
                
                // Have we enabled the plugin?
                if ($this->getSettings()->expandSingles) {

                    foreach ($event->linkOptions as $i => $linkOption) {

                        // Only apply this for entries, and if there are any singles
                        if ($linkOption['refHandle'] === 'entry') {
                            if (in_array('singles', $linkOption['sources'])) {
                                $modifiedSources = $this->singlesList->createSectionedSinglesList($linkOption['sources']);

                                if ($modifiedSources) {
                                    $event->linkOptions[$i]['sources'] = $modifiedSources;
                                }
                            }
                        }
                    }
                }
            });
        }
    }
610758
public function delete( $id ) {

		$container = $this->read( $id );

		foreach ( $container->getLinkedList() as $linkedId ) {
			$key = $this->getKey( (string)$linkedId );
			$this->cache->delete( $key );
			$this->internalCache->delete( $key );
		}

		$this->cache->delete( $this->getKey( $id ) );
		$this->internalCache->delete( $this->getKey( $id ) );
	}
996508
public function from($from = null) {
        if ($from === null) {
            return $this->from;
        }

        $this->from = (int) $from;

        return $this;
    }
1156020
public function handle($object, $fromDatabase = true)
    {
        if (!$this->entityStates->contains($object)) {
            $this->createState($object, $fromDatabase);
        }

        return $object;
    }
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();
	}
805615
protected function init(bool $hasChanged = false): void
    {
        parent::init($hasChanged);

        $originalData = $this->data;

        if ($this->isRaw) {
            $this->useFileReference = true;
            $this->data = new Data;
        } else {
            /** @var InternetMediaTypeInterface $internetMediaType */
            $internetMediaType = $this->analyzer->detectFromFilename($this->file);

            if ($internetMediaType &&
                ('text' === $internetMediaType->getType() ||
                $this->applicationXmlType->equals($internetMediaType))) {
                // Only text files can be processed by Sculpin and since we
                // have to read them here we are going to ensure that we use
                // the content we read here instead of having someone else
                // read the file again later.
                $this->useFileReference = false;

                // Additionally, any text file is a candidate for formatting.
                $this->canBeFormatted = true;

                $content = file_get_contents((string)$this->file);

                if (preg_match('/^\s*(?:---[\s]*[\r\n]+)(.*?)(?:---[\s]*[\r\n]+)(.*?)$/s', $content, $matches)) {
                    $this->content = $matches[2];
                    if (preg_match('/^(\s*[-]+\s*|\s*)$/', $matches[1])) {
                        // There is nothing useful in the YAML front matter.
                        $this->data = new Data;
                    } else {
                        // There may be YAML frontmatter
                        try {
                            $builder = new YamlDataBuilder($matches[1]);
                            $this->data = $builder->build();
                        } catch (\InvalidArgumentException $e) {
                            // Likely not actually YAML front matter available,
                            // treat the entire file as pure content.
                            echo ' ! ' . $this->sourceId() . ' ' . $e->getMessage() . ' !' . PHP_EOL;
                            $this->content = $content;
                            $this->data = new Data;
                        }
                    }
                } else {
                    $this->content = $content;
                    $this->data = new Data;
                    $this->canBeFormatted = false;
                }
            } else {
                $this->useFileReference = true;
                $this->data = new Data;
            }
        }

        if ($this->data->get('date')) {
            if (! is_numeric($this->data->get('date'))) {
                $this->data->set('date', strtotime($this->data->get('date')));
            }

            $this->data->set('calculated_date', $this->data->get('date'));
        }

        if ($originalData) {
            $this->data->import($originalData, false);
        }
    }
1222136
public function execute()
    {
        try
        {
            if (!$this->_prepared) {
                // includes generated template PHP code
                $this->prepare();
            }
            $this->_context->echoDeclarations(false);

            $templateFunction = $this->getFunctionName();

            try {
                ob_start();
                $templateFunction($this, $this->_context);
                $res = ob_get_clean();
            }
            catch (Exception $e)
            {
                ob_end_clean();
                throw $e;
            }

            // unshift doctype
            if ($this->_context->_docType) {
                $res = $this->_context->_docType . $res;
            }

            // unshift xml declaration
            if ($this->_context->_xmlDeclaration) {
                $res = $this->_context->_xmlDeclaration . "\n" . $res;
            }

            if ($this->_postfilter) {
                return $this->_postfilter->filter($res);
            }
        }
        catch (Exception $e)
        {
            PHPTAL_ExceptionHandler::handleException($e, $this->getEncoding());
        }

        return $res;
    }
1034248
function doc(): Result {
    return $this->collectionBuilder()
      ->addTask($this->taskFilesystemStack()
        ->copy('CHANGELOG.md', 'doc/about/changelog.md')
        ->copy('LICENSE.md', 'doc/about/license.md'))
      ->addTask($this->taskExec('mkdocs build --config-file=etc/mkdocs.yaml'))
      ->addTask($this->taskFilesystemStack()
        ->remove(['doc/about/changelog.md', 'doc/about/license.md']))
      ->run();
  }
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;
    }
1150240
public function replace($from, $to)
    {
        $values = $this->_replace($from, $to);
        return new Collection($values);
    }
151136
public function methodDoc(&$methods)
    {
        $this->depth++;
        if ($methods) {
            foreach ($methods as $method) {
                $type = $method->returnType();
                echo $this->showDepth(), '- ', $method->modifiers();
                if ($type) {
                    echo $type->toString(), ' ';
                } else {
                    echo 'void ';
                }
                echo $method->packageName(), '\\', $method->name(), $method->flatSignature();
                echo ' [', $method->location(), ']';
                echo "\n";
                $this->fieldDoc($method->parameters());
                $this->methodDoc($method->functions());
                $exceptions =& $method->thrownExceptions();
                if ($exceptions) {
                    foreach ($exceptions as $exception) {
                        echo $this->showDepth(), '|- throws ';
                        if (is_object($exception)) {
                            echo $exception->packageName(), '\\', $exception->name(), "\n";
                        } else {
                            echo $exception, "\n";
                        }
                    }
                }
                $this->docComment($method);
            }
        }
        $this->depth--;
    }
452791
public function execute($objectContext)
    {
        if (method_exists($objectContext, $this->method))
        {
            if (!empty($this->parameters))
            {
                $objectContext->{$this->method}($this->parameters);
            }
            else
            {
                $objectContext->{$this->method}($this->parameters);
            }
        }
    }
586289
public function delete($from)
    {
        $builder               = new Delete($this->driver);
        $this->lastQuery       = $builder;

        return $builder->from($from);
    }
539929
public function where() {
        $this->logic('AND');
        $args = func_get_args();
        switch (count($args)) {
        case 1:
            if (is_array($args[0])) {
                $args[0] = $this->whereArray($args[0]);
            }
            $this->build()->bindExpression('where', $args[0]);
            break;
        case 2:
            $this->build()->bindExpression('where', "{$args[0]} = ?");
            $this->build()->bindParams('where', $args[1]);
            break;
        case 3:
            $this->build()->bindExpression('where', "{$args[0]} {$args[1]} ?");
            $this->build()->bindParams('where', $args[2]);
            break;
        }

        return $this->connection;
    }
1234241
function(nombre, controlador, tags, opciones) {
    // Se establecen los objetos comunes a todos los dispositivos
    this.info = Object();
    this.info.nombre = nombre;
    this.conectado = false;
    this.noErrores = true;
    this.cola = new objCola();
    this.funciones = new funciones(this);
    this.log = new log(this.info.nombre);
    this.tags = tags;
    this.tiposMB = {
        BYTE: {bits: 8, funcion: 'Int8', endian: false},
        INT: {bits: 16, funcion: 'Int16', endian: true},
        UINT: {bits: 16, funcion: 'UInt16', endian: true},
        DINT: {bits: 32, funcion: 'Int32', endian: true},
        UDINT: {bits: 32, funcion: 'UInt32', endian: true}, 
        FLOAT: {bits: 32, funcion: 'Float', endian: true},
        DOUBLE: {bits: 64, funcion: 'Double', endian: true}
    }
    new require('./drivers/'+controlador+'/driver') (this); // Se integran las funciones del driver con el dispositivo actual
    utilidades.mezclarObjetos(opciones, this.info); // Se establecen los objetos particulares de cada dispositivo
    
    this.conectarRecursiva(); // Se conecta el dispositivo
    
    
    
    
    /*
     * Se establecen los eventos o Listeners que serán ejecutados en TODOS los dispositivos, sean del driver que sea
     */
    utilidades.eventos(this, {
        conexion: function() {
            this.conectado = true;
            this.comenzarCiclo();
            this.comprobarConexion();
            
            this.log.info("Conectado");
            this.emit("conectado");
        },
        desconexion: function() {
            if (this.conectado) {
                this.conectado = false;
               
                this.cola.vaciar();
                
                this.log.error("Desconectado");
                this.emit("desconectado");
                this.conectarRecursiva();
            }
        },
        datosRecibidos: function(datos) {
            var buffer = utilidades.extractorBuffer(datos, this.estructuraCabecera, this.tiposMB, this.bytesPorPosicion, this.endian, this.noErrores);   
            if (typeof this.cola.operaciones[buffer.operacion] === 'undefined') {
                this.cola.prepararCola();
                return false;
            }
            
            var numOperacion = buffer.operacion;
            var operacion = this.cola.operaciones[numOperacion];
            var numPaquete = operacion.paquete;
            var paquete = this.cola.paquetes[numPaquete];

            if ((paquete.operaciones.lastIndexOf(numOperacion) === -1) || (typeof this.funciones[paquete.funcion+"Callback"] === 'undefined')) {
                this.cola.prepararCola();
                return false;
            }
            
            var informacion = this.funciones[paquete.funcion+"Callback"](buffer, numOperacion, operacion, numPaquete, paquete);            
            if (paquete.operaciones.length == 1) {
                if (this.cola.quitarPaquete(numPaquete)) {
                    if (typeof paquete.callback == 'function') {
                        if (typeof informacion == 'object') {
                            var array = utilidades.obj2arr(informacion);
                        }

                        paquete.callback.apply(this, array);
                    }
                }
            } else {
                this.cola.quitarOperacion(numOperacion);
            }
            
            this.cola.prepararCola();
            return true;
        },
        error: function() {
            if (this.conectado) {
                this.log.error("Se ha producido un error. Reconectamos el dispositivo...");
                this.emit("desconexion");
            }
        }
    });

    // Alias para los eventos
    this.on("conectado", function() {
        this.emit("connected");
    });
    this.on("desconectado", function() {
        this.emit("disconnected");
    });
    
    
    events.call(this); // Función de llamada a los eventos personalizados
}