Handles the path prefix generation.

Overload this method as needed with your custom implementation.

@param \Cake\Datasource\EntityInterface $entity
@param $path string
@param $config array
@return string
14277
protected function _pathPrefix(EntityInterface $entity, $path, array $config) {
		return $this->_pathPreAndSuffix($entity, $path, $config, 'prefix');
	}
497916
public static function newInstance(EntityInterface $entity, string $path, string $name = null): self
    {
        if (null === $name) {
            $name = $entity->basename();
        }
        $instance = new static($name, $path);
        $instance->realEntity = $entity;

        return $instance;
    }
1246015
public function renderEntityTemplate(EntityTemplate $template, Entity $entity, $path)
    {
        $template->setEntity($entity);

        $fileCollection = new FileCollection();

        $entityPath = $path . $template->getPath();

        $entityName = $template->getFilename();

        if ($entity->shouldRender($template->getTemplateName())) {
            $fileCollection->add(new File($entityPath, $entityName, $template->render()));
        } else {
            $fileCollection->add(new NoFile($entityPath, $entityName, sprintf('The entity \'%s\' is should not have a \'%s\'.', $entity->getFullyQualifiedName(), $template->getTemplateName())));
        }

        return $fileCollection;
    }
365176
protected function _resolveBundle(EntityInterface $entity)
    {
        $bundle = $this->config('bundle');
        if (is_callable($bundle)) {
            $callable = $this->config('bundle');
            $bundle = $callable($entity);
        }

        return (string)$bundle;
    }
1145382
public function prefixPath($locale, $path)
    {
        if (isset($this->localesConfig[$locale]['prefix'])) {
            return $this->localesConfig[$locale]['prefix'].$path;
        }

        return $path;
    }
460209
protected function inpathCE($path, $parent) {
		return (!$this->encoding)? $this->_inpath($path, $parent) : $this->convEncOut($this->_inpath($this->convEncIn($path), $this->convEncIn($parent)));
	}
687673
public function generateProxyClass($entity, $config)
    {
        if (!is_array($config) && !$config instanceof \ArrayAccess) {
            throw new Exception\InvalidArgumentException(
                'Invalid proxy class configuration; array or instance of ArrayAccess expected');
        }
        
        if (!is_object($entity)) {
            if ((is_string($entity) && (!class_exists($entity))) // non-existent class
                    || (!is_string($entity)) // not an object or string
            ) {
                throw new Exception\InvalidArgumentException(sprintf(
                        '%s expects an object or valid class name; received "%s"',
                        __METHOD__,
                        var_export($entity, 1)
                ));
            }
        }
        
        $this->serviceConfig = $config;
        
        $reflection  = new ReflectionClass($entity);
        $className = $reflection->getName();
        
        $class = ClassGenerator::fromArray([
            'name' => $this->getProxyClassName($className),
            'namespace_name' => $this->getProxyNamespace($className),
            'extended_class' => '\\' . $className,
            'implemented_interfaces' => array('\Zend\EventManager\EventManagerAwareInterface'),
            'methods' => $this->generateMethods($reflection),
            'properties' => [
                new PropertyGenerator('__wrappedObject', null, PropertyGenerator::FLAG_PUBLIC),
                new PropertyGenerator('__eventManager', null, PropertyGenerator::FLAG_PRIVATE),
                new PropertyGenerator('__commandStack', null, PropertyGenerator::FLAG_PRIVATE)
            ]
        ]);
        
        $source = "<?php\n" . $class->generate();
        
        $fileName        = $this->getProxyFileName($className);
        $parentDirectory = $this->proxyDirectory;
        
        if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
            throw new Exception\RuntimeException('Proxy directory '.$parentDirectory.' not found');
        }
        
        if ( ! is_writable($parentDirectory)) {
            throw new Exception\RuntimeException('Proxy directory '.$parentDirectory.' is not writable');
        }
        
        $tmpFileName = $fileName . '.' . uniqid('', true);
        file_put_contents($tmpFileName, $source);
        rename($tmpFileName, $fileName);
    }
1314689
protected function _getUrl($entity, $field)
    {
        $path = '/' . $this->_getPath($entity, $field, ['root' => false, 'file' => true]);
        return str_replace(DS, '/', $path);
    }
1323777
public function vaidateEntityConfig($entityName, $entity)
  {

    if (empty($entity->requests))
    {
      $this->printMessage(
        "Entity: {$entityName} doesn't have any requests set up for it."
        . " Controllers, exceptions, requests will be skipped."
      );
    }
    else
    {
      foreach ($entity->requests as $requestMethod => $actions)
      {
        foreach ($actions as $actionName => $action)
        {
          if (empty($action->url))
          {
            $this->printMessage(
              "Entity: {$entityName}::{$actionName} doesn't have a url set."
              . " This action will be skipped."
            );
            $entity->requests->$requestMethod->$actionName = false;
          }

          if (!empty($action->throws))
          {
            if (!empty($action->throws->extends))
            {
              if (!class_exists("Phrest\\API\\Exceptions\\" . $action->throws->extends))
              {
                $this->printMessage(
                  "Entity: {$entityName}::{$actionName} Unknown exception: "
                  . "Phrest\\API\\Exceptions\\" . $action->throws->extends
                  . ". This extension will be removed."
                );
                $action->throws->extends = false;
              }
            }
          }
        }
      }
    }

    if (empty($entity->model))
    {
      $this->printMessage(
        "Entity: {$entityName} doesn't have a model definition. Models and "
        . "responses will be skipped."
      );
    }

    return $entity;
  }
878442
public function encryptEntity(EntityInterface $entity): EntityInterface
    {
        if (!$this->isEncryptable($entity)) {
            return $entity;
        }

        $fields = $this->getFields();
        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $table = $this->getTable();

        $patch = [];
        foreach ($fields as $name => $field) {
            if (!$table->hasField($name)) {
                continue;
            }
            $value = $entity->get($name);
            if ($value === null || is_resource($value)) {
                continue;
            }
            $encrypted = Security::encrypt($value, $encryptionKey);
            if ($base64 === true) {
                $encrypted = base64_encode($encrypted);
            }
            $patch[$name] = $encrypted;
        }

        if (!empty($patch)) {
            $accessible = array_fill_keys(array_keys($patch), true);
            $entity = $table->patchEntity($entity, $patch, [
                'accessibleFields' => $accessible,
            ]);
        }

        return $entity;
    }
682471
protected function _prepareCachedColumns(EntityInterface $entity)
    {
        if ($this->config('cacheMap')) {
            foreach ((array)$this->config('cacheMap') as $column => $fields) {
                if (in_array($column, $entity->visibleProperties())) {
                    $string = $entity->get($column);
                    if ($string == serialize(false) || unserialize($string) !== false) {
                        $entity->set($column, unserialize($string));
                    } else {
                        $entity->set($column, new CachedColumn());
                    }
                }
            }
        }

        return $entity;
    }
891662
protected function beforeSave(EntityInterface $entity): EntityInterface
    {
        $argv = compact('entity');
        $argv = $this->getEventManager()->prepareArgs($argv);

        $this->getEventManager()->trigger("{$this->event_prefix}_save_before", $this, $argv);
        if ($this->entity_event_prefix) {
            $this->getEventManager()->trigger("{$this->entity_event_prefix}_save_before", $this, $argv);
        }

        return $argv['entity'];
    }
834474
public String updateByPath(String path,String entity) throws ElasticSearchException{
		try {
			return this.client.executeHttp(path, entity, ClientUtil.HTTP_POST);
		}
		catch(ElasticSearchException e){
			return ResultUtil.hand404HttpRuntimeException(e,String.class,ResultUtil.OPERTYPE_updateDocument);
		}
	}
594296
public function afterSave(Event $event, EntityInterface $entity) {
		if ($this->_checkEvent($event) && $entity->isNew()) {
			$fileField = $this->getConfig('fileField');

			$hash = StorageUtils::getFileHash($entity->get($fileField)['tmp_name']);
			$path = $this->pathBuilder()->fullPath($entity);

			$entity->set('hash', $hash);
			$entity->set('path', $path);

			if (!$this->_storeFile($event)) {
				return;
			}

			$event->result = true;
			$event->stopPropagation();
		}
	}
328771
protected function initEntity(IFormEntity $entity, array $config)
    {
        foreach ($config as $name => $value) {
            $this->createAnnotation($name, $value)
                ->transform($entity);
        }
    }
723953
public function setEntityUrl($entity, $ormMethod, $params = [])
    {
        $className = $this->_getEntityClassName($entity);
        if (!isset($this->_entityConfiguration[$className]->methods[$ormMethod])) {
            throw new \Exception('ORM method ' . $ormMethod . ' not available for entity:' . $className);
        }
        
        $url = $this->_entityConfiguration[$className]->methods[$ormMethod]['resource'];
        $matches = [];
        preg_match_all('/\\:\\w+/', $url, $matches);

        $configuration_vars = $this->_config->all();
        
        foreach ($matches[0] as $match) {
          $key = substr($match, 1);

            if (array_key_exists($key, $params)) {
                $url = str_replace($match, $params[$key], $url);
            } elseif (array_key_exists(strtoupper($key), $configuration_vars)) {
                $url = str_replace($match, $configuration_vars[strtoupper($key)]);
            } elseif (!empty($entity->$key)) {
                $url = str_replace($match, $entity->$key, $url);
            } else {
                $url = str_replace($match, $entity->{$key}, $url);
            }
        }
        $this->_entityConfiguration[$className]->url = $url;
    }
292537
protected function formatKeyCondition(EntityInterface $entity)
    {
        $attributes = array(
            $entity::getHashKeyAttribute() => $entity->getHashKey(),
        );

        $rangeKeyAttribute = $entity::getRangeKeyAttribute();
        if ($rangeKeyAttribute !== false) {
            $attributes[$rangeKeyAttribute] = $entity->getRangeKey();
        }

        return $this->formatAttributes(get_class($entity), $attributes);
    }