Example: getHelpForImage($task, 'imageFile')

@param object $entity
@param string $fieldName
@return string
15593
protected function getHelpForImage($entity, $fieldName)
    {
        $container        = $this->getConfigurationPool()->getContainer();
        $annotationReader = $container->get('annotation_reader');

        $reflectionClass = new \ReflectionClass(get_class($entity));
        $annotation = $annotationReader->getPropertyAnnotation($reflectionClass->getProperty($fieldName), Image::class);
        $imageHelp = sprintf('Допустимый размер %s*%s', $annotation->minWidth, $annotation->minHeight);

        return $imageHelp;
    }
1068377
protected function getSetterName($entity, $propertyName)
    {
        $prefixes = ['add', 'set'];

        foreach ($prefixes as $prefix) {
            $methodName = sprintf('%s%s', $prefix, ucfirst(strtolower($propertyName)));

            if (method_exists($entity, $methodName)) {
                return $methodName;
            }
        }
        return false;
    }
864508
final protected function getTypeFromReturnTypeHint(ReflectionMethod $method, string $fieldName): ?Type
    {
        $returnType = $method->getReturnType();
        if (!$returnType) {
            return null;
        }

        $returnTypeName = (string) $returnType;
        if (is_a($returnTypeName, Collection::class, true) || $returnTypeName === 'array') {
            $targetEntity = $this->getTargetEntity($fieldName);
            if (!$targetEntity) {
                throw new Exception('The method ' . $this->getMethodFullName($method) . ' is type hinted with a return type of `' . $returnTypeName . '`, but the entity contained in that collection could not be automatically detected. Either fix the type hint, fix the doctrine mapping, or specify the type with `@API\Field` annotation.');
            }

            $type = Type::listOf($this->getTypeFromRegistry($targetEntity, false));
            if (!$returnType->allowsNull()) {
                $type = Type::nonNull($type);
            }

            return $type;
        }

        return $this->reflectionTypeToType($returnType);
    }
518548
public function imageVersionPath(EntityInterface $entity, $version, $type = 'fullPath', $options = []) {
		if (empty($version)) {
			// Temporary fix for GH #116, this should be fixed in the helper and by
			// introducing getting an URL by event as well in the long run.
			return $this->pathBuilder()->url($entity, $options);
		}

		$hash = $this->getImageVersionHash($entity->model, $version);

		$output = $this->_defaultOutput + ['format' => $entity->extension];
		$operations = $this->_imageVersions[$entity->model][$version];
		if (isset($operations['_output'])) {
			$output = $operations['_output'] + $output;
		}

		$options += [
			'preserveExtension' => false,
			'fileSuffix' => '.' . $hash . '.' . $output['format']
		];

		return $this->pathBuilder()->{$type}($entity, $options);
	}
1282969
public function guessChoiceLabelFromClass($entity)
    {
        $metadata = $this->metadataFactory->getClassMetadata($entity)->getMetadata();
        foreach ($metadata[0]->fieldMappings as $fieldName => $field) {
            if ($field['type'] == 'string') {
                return $fieldName;
            }
        }
        //if no string field found, return id
        return 'id';
    }
515371
public static function getFieldValue(PageInterface $object, $fieldName, $method = null)
    {
        $getters = [];
        // prefer method name given in the code option
        if ($method) {
            $getters[] = $method;
        }

        $camelizedFieldName = self::camelize($fieldName);
        $getters[] = 'get'.$camelizedFieldName;
        $getters[] = 'is'.$camelizedFieldName;

        foreach ($getters as $getter) {
            if (method_exists($object, $getter)) {
                return call_user_func([$object, $getter]);
            }
        }

        throw new NoValueException(sprintf('Unable to retrieve the value of `%s`', $camelizedFieldName));
    }
281159
public function & GetField ($fieldName = '') {
		$result = NULL;
		if (isset($this->fields[$fieldName]))
			$result = & $this->fields[$fieldName];
		return $result;
	}
1237064
protected function getFieldContent($entity, $fieldName, array $fieldAttr, array $mappings)
    {
        if (isset($fieldAttr['widget'])) {
            $widgetAlias = $fieldAttr['widget']['alias'];

            return $this->widgetPool->getWidget($widgetAlias)->getContent(
                $entity,
                $fieldAttr['widget']['options'],
                $fieldName
            );
        }
        if (isset($fieldAttr['service'])) {
            $method = $fieldAttr['service']['method'];

            return $this->container->get($fieldAttr['service']['id'])->$method($entity, $fieldAttr['service']['options']);
        }
        if (isset($fieldAttr['callback'])) {
            $class = $fieldAttr['callback']['class'];
            $method = $fieldAttr['callback']['method'];

            return $class::$method($entity, $fieldAttr['callback']['options']);
        }

        $content = $this->propertyAccessor->getValue($entity, $fieldName);

        return isset($mappings[$fieldName]['type'])
            ? $this->stringifier->stringify($content, $mappings[$fieldName]['type'])
            : $content;
    }
1298058
public function getEntityClassName($entity)
    {
        if (array_key_exists($entity, $this->entityMap)) {
            return $this->entityMap;
        }

        return $this->rootEntityNamespace . $entity;
    }
601322
public function setFieldValue($entity, $fieldName, $value)
    {
        if ($this->fieldMappings[$fieldName]['direct']) {
            $this->reflFields[$fieldName]->setValue($entity, $value);
        } else {
            if (!array_key_exists('setMethod', $this->fieldMappings[$fieldName])) {
                $this->fieldMappings[$fieldName]['setMethod'] = $this->inferSetter($fieldName);
            }
            $setter = $this->fieldMappings[$fieldName]['setMethod'];

            if ($this->reflClass->hasMethod($setter)) {
                return call_user_func(array($entity, $setter), $value);
            } else {
                throw MappingException::fieldSetMethodDoesNotExist($this->name, $fieldName, $setter);
            }
        }
    }
328948
public function getFieldValue($object, $fieldName, $method = null)
    {
        $getters = [];
        // prefer method name given in the code option
        if ($method) {
            $getters[] = $method;
        }

        $camelizedFieldName = self::camelize($fieldName, true);
        $getters[] = 'get'.$camelizedFieldName;
        $getters[] = 'is'.$camelizedFieldName;

        foreach ($getters as $getter) {
            if (method_exists($object, $getter)) {
                return call_user_func([$object, $getter]);
            }
        }

        return '';
    }
283650
protected function _translateFieldname(string $fieldname, string $model): string
    {
        // Try to get the generic model.field translation string
        $localeSlug = strtolower(Inflector::singularize(Inflector::delimit($model))) . '.' . strtolower($fieldname);
        $translatedString = __($localeSlug);

        // Return original value when no translation was made
        if ($localeSlug == $translatedString) {
            return $fieldname;
        }

        return $translatedString;
    }
1314689
protected function _getUrl($entity, $field)
    {
        $path = '/' . $this->_getPath($entity, $field, ['root' => false, 'file' => true]);
        return str_replace(DS, '/', $path);
    }
790344
public function getTranslation($entity, $property, $locale)
    {
        $metadata = $this->metadataCollection->getMetadata($entity);
        if($metadata === null) {
            return null;
        }

        $property = $metadata->getProperty($property);
        if($property === null) {
            return null;
        }

        $strategy = $this->strategyResolver->getStrategy($property->getStrategy());
        return $strategy->getTranslation($entity, $property, $locale, $metadata);
    }
174779
public function load(Entity $entity)
    {
        $data = $entity->getRawData();
        if (!is_array($data) || !isset($data[$this->getForeignKey()])) {
            return null;
        }
        /** @var Select $sql */
        $sql = call_user_func_array(
            [$this->getRelatedEntity(), 'find'],
            []
        );
        $pmk = Entity\Manager::getInstance()->get($this->getRelatedEntity())
            ->getEntity()->getPrimaryKey();
        $table = Entity\Manager::getInstance()->get($this->getRelatedEntity())
            ->getEntity()->getTableName();
        $sql-> where(
            [
                "{$table}.{$pmk} = :id" => [
                    ':id' => $data[$this->getForeignKey()]
                ]
            ]
        );
        return $sql->first();
    }
960801
protected function guessSingularField($entity, $field = null)
    {
        return $field ?: Inflector::singularize(
            lcfirst(basename(str_replace('\\', '/', $entity)))
        );
    }
216686
private function __getFileName($fileInfo, EntityInterface $entity, $id = 0)
    {
        if (!file_exists(Configure::read('Attachments.path') . $entity->source() . '/' . $entity->id . '/' . $fileInfo['basename'])) {
            return $fileInfo;
        }
        $fileInfo['basename'] = $fileInfo['filename'] . ' (' . ++$id . ').' . $fileInfo['extension'];
        return $this->__getFileName($fileInfo, $entity, $id);
    }