Overview

Namespaces

  • LeanMapper
    • Bridges
      • Nette
        • DI
    • Exception
    • Reflection
    • Relationship

Classes

  • LeanMapper\Bridges\Nette\DI\LeanMapperExtension
  • LeanMapper\Caller
  • LeanMapper\Connection
  • LeanMapper\DataDifference
  • LeanMapper\DefaultEntityFactory
  • LeanMapper\DefaultMapper
  • LeanMapper\Entity
  • LeanMapper\EntityDataDecoder
  • LeanMapper\Events
  • LeanMapper\Filtering
  • LeanMapper\FilteringResult
  • LeanMapper\FilteringResultDecorator
  • LeanMapper\Fluent
  • LeanMapper\ImplicitFilters
  • LeanMapper\Reflection\Aliases
  • LeanMapper\Reflection\AliasesBuilder
  • LeanMapper\Reflection\AliasesParser
  • LeanMapper\Reflection\AnnotationsParser
  • LeanMapper\Reflection\EntityReflection
  • LeanMapper\Reflection\Property
  • LeanMapper\Reflection\PropertyFactory
  • LeanMapper\Reflection\PropertyFilters
  • LeanMapper\Reflection\PropertyMethods
  • LeanMapper\Reflection\PropertyPasses
  • LeanMapper\Reflection\PropertyType
  • LeanMapper\Reflection\PropertyValuesEnum
  • LeanMapper\Relationship\BelongsTo
  • LeanMapper\Relationship\BelongsToMany
  • LeanMapper\Relationship\BelongsToOne
  • LeanMapper\Relationship\HasMany
  • LeanMapper\Relationship\HasOne
  • LeanMapper\Repository
  • LeanMapper\Result
  • LeanMapper\ResultProxy
  • LeanMapper\Row

Interfaces

  • LeanMapper\IEntityFactory
  • LeanMapper\IMapper

Exceptions

  • LeanMapper\Exception\Exception
  • LeanMapper\Exception\InvalidAnnotationException
  • LeanMapper\Exception\InvalidArgumentException
  • LeanMapper\Exception\InvalidMethodCallException
  • LeanMapper\Exception\InvalidStateException
  • LeanMapper\Exception\InvalidValueException
  • LeanMapper\Exception\MemberAccessException
  • LeanMapper\Exception\UtilityClassException
  • Overview
  • Namespace
  • Class
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 
<?php

/**
 * This file is part of the Lean Mapper library (http://www.leanmapper.com)
 *
 * Copyright (c) 2013 Vojtěch Kohout (aka Tharos)
 *
 * For the full copyright and license information, please view the file
 * license.md that was distributed with this source code.
 */

namespace LeanMapper;

use Closure;
use LeanMapper\Exception\InvalidArgumentException;

/**
 * \Dibi\Fluent with filter support
 *
 * @author Vojtěch Kohout
 */
class Fluent extends \Dibi\Fluent
{

    /** @var array */
    public static $masks = [ // fixes missing UNION in dibi
        'SELECT' => [
            'SELECT', 'DISTINCT', 'FROM', 'WHERE', 'GROUP BY',
            'HAVING', 'ORDER BY', 'LIMIT', 'OFFSET', 'UNION',
        ],
        'UPDATE' => ['UPDATE', 'SET', 'WHERE', 'ORDER BY', 'LIMIT'],
        'INSERT' => ['INSERT', 'INTO', 'VALUES', 'SELECT'],
        'DELETE' => ['DELETE', 'FROM', 'USING', 'WHERE', 'ORDER BY', 'LIMIT'],
    ];

    /** @var array|null */
    private $relatedKeys;



    /**
     * Applies given filter to current statement
     *
     * @param Closure|string $filter
     * @param mixed|null $args
     * @return FilteringResult|null
     */
    public function applyFilter($filter, $args = null)
    {
        $args = func_get_args();
        $args[0] = $this;
        return call_user_func_array(
            $filter instanceof Closure ? $filter : $this->getConnection()->getFilterCallback($filter),
            $args
        );
    }



    /**
     * @param array|null $args
     * @return self
     */
    public function createSelect($args = null)
    {
        return call_user_func_array([$this->getConnection(), 'select'], func_get_args());
    }



    /**
     * Exports current state
     *
     * @param string|null $clause
     * @param array|null $args
     * @return array
     */
    public function _export($clause = null, $args = null)
    {
        $args = func_get_args();

        $reflector = new \ReflectionClass(get_class($this));
        $parent = $reflector->getParentClass();
        $method = $parent->getMethod('_export');
        $method->setAccessible('true');
        return $method->invokeArgs($this, $args);
    }



    /**
     * @return array|null
     */
    public function getRelatedKeys()
    {
        return $this->relatedKeys;
    }



    /**
     * @param array|null $keys
     * @return self
     * @throws InvalidArgumentException
     */
    public function setRelatedKeys($keys)
    {
        if (!is_array($keys) and $keys !== null) {
            throw new InvalidArgumentException('Invalid related keys given. Expected array or null, ' . gettype($keys) . ' given.');
        }
        $this->relatedKeys = $keys;
        return $this;
    }

}
tharos/leanmapper v3.3.0 API documentation API documentation generated by ApiGen