Return query to find the mapping for given parent id, parent type and mapping type.

@param integer $parentId
@param string $parentType
@param string $type
@return \yii\db\ActiveQuery to find using parent id, parent type and mapping type.
180965
public static function queryByTypeParent( $parentId, $parentType, $type ) {

		$tableName = static::tableName();

		return self::queryWithModel()->where( "$tableName.parentId=:pid AND $tableName.parentType=:ptype AND $tableName.type=:type", [ ':pid' => $parentId, ':ptype' => $parentType, ':type' => $type ] );
	}
272281
protected function matchToMorphParents($type, EntityCollection $results, array $parents)
    {
        $mapper = $this->relatedMapper->getManager()->mapper($type);
        $keyName = $mapper->getEntityMap()->getKeyName();

        $keys = array_map(function ($parent) use ($keyName) {
            return $parent[$keyName];
        }, $parents);

        $parents = array_combine($keys, $parents);

        foreach ($results as $result) {
            $key = $result[$keyName];

            if (isset($this->dictionary[$type][$key])) {
                foreach ($this->dictionary[$type][$key] as $parent) {
                    $parents[$parent[$keyName]][$this->relation] = $result;
                }
            }
        }

        return array_values($parents);
    }
570196
public function findAllExceptTreeByParentId($parent_id)
    {
        $qb = $this->createQueryBuilder();

        $qb = $this->alterQueryBuilderExceptWithParentRoot($qb, $parent_id);

        $qb->orderBy($qb->getRootAliases()[0] . '.lft', 'ASC');

        return $this->getResultFromQueryBuilder($qb);
    }
861649
public function getCountByParent( $parentId, $parentType ) {

		$modelClass	= static::$modelClass;

		return $modelClass::queryByParent( $parentId, $parentType )->count();
	}
379621
public static function isExistByNameType( $parentId, $parentType, $name, $type, $config = [] ) {

		$meta = self::queryByNameType( $parentId, $parentType, $name, $type, $config )->one();

		return isset( $meta );
	}
363048
public static function findByFileTag( $parentId, $parentType, $fileTag, $type = null ) {

		$mapTable	= static::tableName();
		$fileTable	= CoreTables::getTableName( CoreTables::TABLE_FILE );

		if( empty( $type ) ) {

			$type = CoreGlobal::TYPE_DEFAULT;
		}

		return self::queryByParent( $parentId, $parentType )->andWhere( "$fileTable.tag=:tag AND $mapTable.type=:type", [ ':tag' => $fileTag, ':type' => $type ] )->one();
	}
139947
public function viewDocumentAction($documentId, $parentType)
    {
        if (null !== $response = $this->checkAuth($this->getAdminResources()->getResource($parentType, static::MODULE_RIGHT), array(), AccessManager::UPDATE)) {
            return $response;
        }

        $fileManager = $this->getFileManager();
        $documentModel = $fileManager->getModelInstance('document', $parentType);

        $document = $documentModel->getQueryInstance()->findPk($documentId);

        $redirectUrl = $document->getRedirectionUrl();

        return $this->render('document-edit', array(
            'documentId' => $documentId,
            'documentType' => $parentType,
            'redirectUrl' => $redirectUrl,
            'formId' => $documentModel->getUpdateFormId(),
            'breadcrumb' => $document->getBreadcrumb(
                $this->getRouter($this->getCurrentRouter()),
                $this->container,
                'documents',
                $this->getCurrentEditionLocale()
            )
        ));
    }
874340
public static function findByType( $parentId, $parentType, $type, $config = [] ) {

		return self::queryByType( $parentId, $parentType, $type, $config )->all();
	}
1072715
public function loadAutogeneratedEntry($action, $parentId = null)
    {
        /** @var $query \eZ\Publish\Core\Persistence\Database\SelectQuery */
        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            '*'
        )->from(
            $this->dbHandler->quoteTable($this->table)
        )->where(
            $query->expr->lAnd(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('action'),
                    $query->bindValue($action, null, \PDO::PARAM_STR)
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('is_original'),
                    $query->bindValue(1, null, \PDO::PARAM_INT)
                ),
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('is_alias'),
                    $query->bindValue(0, null, \PDO::PARAM_INT)
                )
            )
        );

        if (isset($parentId)) {
            $query->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('parent'),
                    $query->bindValue($parentId, null, \PDO::PARAM_INT)
                )
            );
        }

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetch(\PDO::FETCH_ASSOC);
    }
637798
public static function findByNameTypeLocaleId( $parentId, $parentType, $name, $type, $localeId ) {

		return self::find()->where( 'parentId=:pid AND parentType=:ptype AND name=:name AND type=:type AND localeId=:lid' )
			->addParams( [ ':pid' => $parentId, ':ptype' => $parentType, ':name' => $name, ':type' => $type, ':lid' => $localeId ] )
			->one();
	}
841749
static public function parentIdAndType($id, $type = 'main')
    {
        $builder = self::where('parent_id', $id);
        $builder->where("is_$type", 1);
        $builder->where("is_hidden", 0);

        return $builder->orderBy("list_$type" . '_order')->get();
    }
200478
public function findAll($parentId, array $query = [])
    {
        $resource = $this->createPartialResourceUrlForList($parentId);
        $data = $this->client->get($resource, $query);

        return $this->createMany(reset($data));
    }
811552
public static function findByParent( $parentId, $parentType, $config = [] ) {

		return self::queryByParent( $parentId, $parentType, $config )->all();
	}
499786
public function deleteByParent( $parentId, $parentType ) {

		//$modelClass	= static::$modelClass;

		//return $modelClass::deleteByParent( $parentId, $parentType );

		$models	= $this->getByParent( $parentId, $parentType );

		foreach ( $models as $model ) {

			$this->delete( $model );
		}
	}
525023
public function getParentOfType($type)
    {
        if (is_a($this, $type)) {
            return $this;
        }
        
        if ($this->parent !== null) {
            return $this->parent->getParentOfType($type);
        }
        
        return false;
    }
611001
public static function isExistByUser( $parentId, $parentType, $userId, $type = ModelComment::TYPE_COMMENT ) {

		$comment = static::findByUser( $parentId, $parentType, $userId, $type );

		return isset( $comment );
	}
1147715
public function saveImageAjaxAction($parentId, $parentType)
    {
        $config = FileConfiguration::getImageConfig();
        return $this->saveFileAjaxAction(
            $parentId,
            $parentType,
            $config['objectType'],
            $config['validMimeTypes'],
            $config['extBlackList']
        );
    }