Builds the path under which the data gets stored in the storage adapter.

@param \Cake\Datasource\EntityInterface $entity
@param array $options
@return string
777495
public function path(EntityInterface $entity, array $options = []) {
		$config = array_merge($this->getConfig(), $options);
		$path = '';
		$path = $this->_pathPrefix($entity, $path, $config);
		$path = $this->_path($entity, $path, $config);
		$path = $this->_pathSuffix($entity, $path, $config);

		return $this->ensureSlash($path, 'after');
	}
1193760
private function getImagePath(FileStorage $entity, string $version) : string
    {
        $hash = (string)Configure::read(sprintf('FileStorage.imageHashes.file_storage.%s', $version));
        if (empty($hash)) {
            return $entity->get('path');
        }

        $event = new Event('ImageVersion.getVersions', $this, [
            'hash' => $hash,
            'image' => $entity,
            'version' => $version,
            'options' => [],
            'pathType' => 'fullPath'
        ]);

        EventManager::instance()->dispatch($event);

        if (! $event->getResult()) {
            return $entity->get('path');
        }

        return file_exists(WWW_ROOT . trim($event->getResult(), DS)) ?
            $event->getResult() :
            $entity->get('path');
    }
840473
public function create(array $options)
    {
        $paths = [];

        $entityClass = $this->getClassName($options['entity-table']);
        $closureClass = $this->getClassName($options['closure-table']);
        $useInnoDB = $options['use-innodb'];
        $stubPrefix = $useInnoDB ? '-innodb' : '';

        $paths[] = $path = $this->getPath($options['entity-table'], $options['migrations-path']);
        $stub = $this->getStub('entity' . $stubPrefix, 'migrations');

        $this->filesystem->put($path, $this->parseStub($stub, [
            'entity_table' => $options['entity-table'],
            'entity_class' => $entityClass
        ]));

        $paths[] = $path = $this->getPath($options['closure-table'], $options['migrations-path']);
        $stub = $this->getStub('closuretable' . $stubPrefix, 'migrations');

        $this->filesystem->put($path, $this->parseStub($stub, [
            'closure_table' => $options['closure-table'],
            'closure_class' => $closureClass,
            'entity_table' => $options['entity-table']
        ]));

        return $paths;
    }
817914
public function attachmentsArea(EntityInterface $entity, array $options = [])
    {
        if ($this->config('includeDependencies')) {
            $this->addDependencies();
        }
        $options = Hash::merge([
            'label' => false,
            'id' => 'fileupload-' . uniqid(),
            'formFieldName' => false,
            'mode' => 'full',
            'style' => '',
            'taggable' => false,
            'isAjax' => false,
            'panelHeading' => __d('attachments', 'attachments'),
            'showIconColumn' => true,
            'additionalButtons' => null
        ], $options);
        return $this->_View->element('Attachments.attachments_area', compact('options', 'entity'));
    }
1324053
public function removeImageVersions(EntityInterface $entity, array $versions, array $options = []) {
		$this->_checkImageVersions($entity->model, $versions);

		$result = [];
		foreach ($versions as $version) {
			$hash = $this->getImageVersionHash($entity->model, $version);
			$path = $this->pathBuilder()->fullPath($entity, ['fileSuffix' => '.' . $hash]);
			$result[$version] = [
				'status' => 'success',
				'hash' => $hash,
				'path' => $path
			];
			try {
				$this->getStorageAdapter($entity->adapter)->delete($path);
			} catch (\Exception $e) {
				$result[$version]['status'] = 'error';
				$result[$version]['error'] = $e->getMessage();
			}
		}

		return $result;
	}
1318950
private function getDrupalEntityPath($type, $entity)
    {
        $uri = entity_uri($type, $entity);

        if (!$uri) {
            throw new \InvalidArgumentException(sprintf("%s: entity type is not supported yet"));
        }

        return $uri['path'];
    }
1294342
public function to(string $path, array $options = []): string
    {
        if ($this->urlGenerator->isValidUrl($path)) {
            return $path;
        }

        list($package, $route) = $this->locate($path, $options);

        // Get the path from route configuration, and append route.
        $locate = $this->route($package)->to($route);

        empty($locate) && $locate = '/';

        return $this->urlGenerator->to($locate);
    }
80978
public function load(EntityInterface $entity)
    {
        $adapter = $this->getAdapter();

        $relTable = $this->getParentTableName();
        $relPmk = $this->getParentPrimaryKey();

        $table = $this->getEntityDescriptor()->getTableName();
        $pmk = $this->getEntityDescriptor()->getPrimaryKey();
        $fnk = $this->getForeignKey();

        $onClause = "{$relTable}.{$relPmk} = {$table}.{$fnk}";

        $data = Sql::createSql($adapter)
            ->select($relTable)
            ->join($table, $onClause, null)
            ->where([
                "{$table}.{$pmk->getField()} = :id" => [
                    ':id' => $entity->{$pmk->getName()}
                ]
            ])
            ->first();

        $relEntity = $this->getParentEntityMapper()->createFrom($data);

        return null == $relEntity ? null :$this->registerEntity($relEntity);
    }
921102
public function editButton(EntityInterface $entity, array $options = []): string
    {
        $options = Hash::merge([
            'url' => null,
            'title' => __d('ck_tools', 'edit'),
            'icon' => 'fa fa-pencil',
            'escape' => false,
            'class' => 'btn btn-default btn-xs btn-edit',
        ], $options);

        $url = $options['url'];
        $title = $options['title'];
        $icon = $options['icon'];
        unset($options['url'], $options['title'], $options['icon']);
        if (!$url) {
            // phpcs:ignore
            list($plugin, $controller) = pluginSplit($entity->source());
            $url = [
                'plugin' => $this->_View->request->plugin,
                'controller' => $controller,
                'action' => 'edit',
                $entity->id,
            ];
            $url = $this->augmentUrlByBackParam($url);
        }
        if ($icon) {
            $title = '<i class="' . $icon . '"></i> ' . '<span class="button-text">' . $title . '</span>';
            $options['escape'] = false;
        }

        return $this->Html->link($title, $url, $options);
    }
1111736
public function afterDelete(Event $event, Entity $entity, ArrayObject $options)
    {
        //Deletes the file
        @unlink($entity->path);

        parent::afterDelete($event, $entity, $options);
    }
258058
public function slug(EntityInterface $entity, array $options = []) {
		$overwrite = isset($options['overwrite']) ? $options['overwrite'] : $this->_config['overwrite'];
		if (!$overwrite && $entity->get($this->_config['overwriteField'])) {
			$overwrite = true;
		}
		if ($overwrite || $entity->isNew() || !$entity->get($this->_config['field'])) {
			$slug = [];
			foreach ((array)$this->_config['label'] as $v) {
				$v = $entity->get($v);
				if ($v !== null && $v !== '') {
					$slug[] = $v;
				}
			}
			$slug = implode($slug, $this->_config['separator']);
			$slug = $this->generateSlug($slug, $entity);
			$entity->set($this->_config['field'], $slug);
		}
	}
1168015
public function buildUrl($entity,$entityConfig) {
        $route = $entityConfig['route'];
        $routeParameters = $entityConfig['routeParameters'];
        $href = '';
        if($route != null){
            $href = $this->generateUrl($route,array_merge(array('id' => $entity->getId()),$routeParameters));
        }
        return $href;
    }
468581
public function beforeSave(Event $event, EntityInterface $entity, \ArrayObject $options): void
    {
        if (!$entity->isNew() && $entity->dirty()) {
            $saveHash = Security::hash(md5(uniqid()));
            if (empty($entity->save_hash)) {
                $entity->save_hash = $saveHash;
                $entity->dirty('save_hash', false);
            }

            $this->_dirtyFields[$entity->id] = $this->_extractDirtyFields($entity);
            $this->_applySaveHash($entity, $saveHash);
        }
    }
1290800
public function createImageVersions(EntityInterface $entity, array $versions, array $options = []) {
		$this->_checkImageVersions($entity->model, $versions);

		$options += $this->_defaultOutput + [
			'overwrite' => true
		];

		$result = [];
		$storage = $this->getStorageAdapter($entity->adapter);
		foreach ($this->_imageVersions[$entity->model] as $version => $operations) {
			if (!in_array($version, $versions)) {
				continue;
			}
			$saveOptions = $options + ['format' => $entity->extension];
			if (isset($operations['_output'])) {
				$saveOptions = $operations['_output'] + $saveOptions;
				unset($operations['_output']);
			}

			$path = $this->imageVersionPath($entity, $version, 'fullPath', $saveOptions);

			try {
				if ($options['overwrite'] || !$storage->has($path)) {
					unset($saveOptions['overwrite']);

					$output = $this->subject->createTmpFile();
					$tmpFile = $this->subject->tmpFile($storage, $this->pathBuilder()->fullPath($entity));
					$this->imageProcessor()->open($tmpFile);
					$this->imageProcessor()->batchProcess($output, $operations, $saveOptions);
					$storage->write($path, file_get_contents($output), true);

					unlink($tmpFile);
					unlink($output);
				}
				$result[$version] = [
					'status' => 'success',
					'path' => $path,
					'hash' => $this->getImageVersionHash($entity->model, $version)
				];
			} catch (\Exception $e) {
				$result[$version] = [
					'status' => 'error',
					'error' => $e->getMessage(),
					'line' => $e->getLine(),
					'file' => $e->getFile()
				];
			}
		}

		return $result;
	}
976426
public function execute($entity, $method = 'get', $options = [])
    {

        $this->cleanQueryParams($entity);
        $configuration = $this->_getEntityConfiguration($entity);

        if ($method != 'get'){
            foreach ($configuration->attributes as $key => $attribute) {
                $this->validateAttribute($entity, $key, ['required']);
            } 
        }

        $this->processOptions($options, $configuration);

        $this->_setDefaultHeaders($configuration->query);
        $this->_setCustomHeaders($entity, $configuration->query);
        //$this->_setIdempotencyHeader($configuration->query, $configuration, $method);
        $this->setQueryParams($entity);
        
        return $this->_client->{$method}($configuration->url, $configuration->query);
    }
859835
public function beforeSave(Event $event, Entity $entity, ArrayObject $options)
    {
        $onUpdate = $this->getConfig('onUpdate');
        if (!$entity->isNew() && !$onUpdate) {
            return;
        }

        $onDirty = $this->getConfig('onDirty');
        $field = $this->getConfig('field');
        if (!$onDirty
            && $entity->isDirty($field)
            && (!$entity->isNew() || (!empty($entity->{$field})))
        ) {
            return;
        }

        $separator = $this->getConfig('separator');
        if ($entity->isDirty($field) && !empty($entity->{$field})) {
            $slug = $this->slug($entity, $entity->{$field}, $separator);
            $entity->set($field, $slug);

            return;
        }

        $parts = $this->_getPartsFromEntity($entity);
        if (empty($parts)) {
            return;
        }

        $slug = $this->slug($entity, implode($separator, $parts), $separator);
        $entity->set($field, $slug);
    }
1255791
public function load(EntityInterface $entity)
    {
        $adapter = $this->getAdapter();
        $relTable = $this->getParentTableName();
        $pmk = $this->getEntityDescriptor()->getPrimaryKey();
        $fnk = $this->getForeignKey();

        $data = Sql::createSql($adapter)
            ->select($relTable)
            ->where([
                "{$relTable}.{$fnk} = :id" => [
                    ':id' => $entity->{$pmk->name}
                ]
            ])
            ->first();

        $relEntity = $this->getParentEntityMapper()->createFrom($data);

        return null == $relEntity ? null :$this->registerEntity($relEntity);
    }