HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/public_html/src/core/Directus/Services/RelationsService.php
<?php

namespace Directus\Services;

use Directus\Application\Container;
use Directus\Database\Schema\SchemaManager;
use Directus\Database\Exception\ForbiddenSystemTableDirectAccessException;

class RelationsService extends AbstractService
{
    /**
     * @var string
     */
    protected $collection;

    /**
     * @var ItemsService
     */
    protected $itemsService;

    /**
     * @var array
     */
    public $restrictedTables = [
        SchemaManager::COLLECTION_ACTIVITY,
        SchemaManager::COLLECTION_COLLECTIONS,
        SchemaManager::COLLECTION_FIELDS,
        SchemaManager::COLLECTION_RELATIONS
    ];

    public function __construct(Container $container)
    {
        parent::__construct($container);

        $this->collection = SchemaManager::COLLECTION_RELATIONS;
        $this->itemsService = new ItemsService($this->container);
    }

    public function throwErrorIfRestrictedTable($name)
    {
        if (in_array($name, $this->restrictedTables)) {
            throw new ForbiddenSystemTableDirectAccessException($name);
        }
    }


    public function create(array $data, array $params = [])
    {
        $this->throwErrorIfRestrictedTable($data['collection_one']);
        return $this->itemsService->createItem($this->collection, $data, $params);
    }

    public function find($id, array $params = [])
    {
        return $this->itemsService->find($this->collection, $id, $params);
    }

    public function findByIds($id, array $params = [])
    {
        return $this->itemsService->findByIds($this->collection, $id, $params);
    }

    public function update($id, array $data, array $params = [])
    {
        $this->throwErrorIfRestrictedTable($data['collection_one']);
        return $this->itemsService->update($this->collection, $id, $data, $params);
    }

    public function delete($id, array $params = [])
    {
        return $this->itemsService->delete($this->collection, $id, $params);
    }

    public function findAll(array $params = [])
    {
        return $this->itemsService->findAll($this->collection, $params);
    }

    public function batchCreate(array $payload, array $params = [])
    {
        return $this->itemsService->batchCreate($this->collection, $payload, $params);
    }

    public function batchUpdateWithIds(array $ids, array $payload, array $params = [])
    {
        return $this->itemsService->batchUpdateWithIds($this->collection, $ids, $payload, $params);
    }

    public function batchDeleteWithIds(array $ids, array $params = [])
    {
        return $this->itemsService->batchDeleteWithIds($this->collection, $ids, $params);
    }
}