@param \Protobuf\Compiler\Entity $entity

@return bool
422806
public function hasDefaultValue(Entity $entity)
    {
        $descriptor = $entity->getDescriptor();
        $fields     = $descriptor->getFieldList() ?: [];

        foreach ($fields as $field) {
            if ( ! $field->hasDefaultValue()) {
                continue;
            }

            return true;
        }

        return false;
    }
641229
public function isRegistered( $entity )
    {
        if( is_object($entity) ) {
            return isset( $this->registrations[get_class($entity)]);
        }

        return isset( $this->registrations[$entity] ) || isset( $this->names[\Bond\get_unqualified_class($entity)] );
    }
1042196
private function hasInDecodedRegistry($entity, EntityManager $em) {
        $className = get_class($entity);
        $metadata = $em->getClassMetadata($className);
        $getter = 'get' . self::capitalize($metadata->getIdentifier());

        return isset($this->decodedRegistry[$className][$entity->$getter()]);
    }
147380
public function one(Entity $entity)
    {
        $data = $entity->getCustomRepositoryCollection();
        $query = $entity->getQuery();

        return $data->first(function(Record $record) use ($query) {
            $where = $query->getWhere();
            if (!$where) {
                return true;
            }

            $children = $where->getChildren();
            $binds = $query->getBinds('where');

            foreach ($children as $i => $child) {
                if (!is_string($child)) {
                    continue;
                }

                if (preg_match('/^`[a-z]*` = \?$/', $child, $matches)) {
                    $field = substr($child, 1, strpos($child, '`', 1) - 1);
                    $value = $binds[$i];
                    
                    return $record->{$field} == $value;
                } else {
                    return false;
                }
            }

            return true;
        });
    }
1204038
protected function loadEntityClass(Entity $entity)
    {
        $type    = $entity->getType();
        $content = $entity->getContent();
        $class   = $entity->getNamespacedName();

        if (class_exists($class) || interface_exists($class)) {
            return false;
        }

        $this->logger->info(sprintf('Loading class "%s"', $class));

        $tempname = tempnam(sys_get_temp_dir(), 'proto') . '.php';

        file_put_contents($tempname, $content);

        include($tempname);
        @unlink($tempname);

        if ($type === Entity::TYPE_EXTENSION) {

            $this->logger->info(sprintf('Registering extension "%s"', $class));

            $config   = $this->config;
            $registry = $config->getExtensionRegistry();

            $class::registerAllExtensions($registry);

            return true;
        }

        return false;
    }
301438
public function isInIdentityMap($entity)
    {
        $oid = spl_object_hash($entity);
        if ( ! isset($this->entityIdentifiers[$oid])) {
            return false;
        }
        $classMetadata = $this->xem->getClassMetadata(get_class($entity));
        $id = $this->entityIdentifiers[$oid];
        if ($id === '') {
            return false;
        }

        return isset($this->identityMap[$classMetadata->rootXmlEntityName][$id]);
    }
488948
public function isManagedByDoctrine($entity)
    {
        $cacheKey  = 'managed';
        $entity    = $this->toString($entity);
        $isManaged = $this->getFromCache($entity, $cacheKey, null);

        if (null !== $isManaged) {
            return $isManaged;
        }

        try {
            $this->managed = $isManaged = (bool) $this->entityManager->getReference($entity, 0);
            $entity = $this->getEntityClassFull($entity);
        } catch (\Exception $e) {
            $isManaged = false;
        }

        $this->cache[$entity][$cacheKey] = $isManaged;

        return $isManaged;
    }
507803
protected function prepareEntityForPersist(AbstractEntity $entity): bool
    {
        if ($entity instanceof TimestampableInterface) {
            $entity->setEditionDate(new DateTime());
        }

        return true;
    }
2383
public function hasDocumentDeclaration($entity)
    {
        if ($rootDocument = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS)) {
            return true;
        }

        if ($this->isNested($entity)) {
            return true;
        }

        return false;
    }
446351
public function isEncryptable(EntityInterface $entity): bool
    {
        $enabled = $this->getConfig('enabled');
        if (is_callable($enabled)) {
            $enabled = $enabled($entity);
            if (!is_bool($enabled)) {
                throw new RuntimeException('Condition callable must return a boolean.');
            }
        }

        return $enabled;
    }
1308098
private function prepareMedia($entity)
    {
        if (!$entity instanceof Media) {
            return false;
        }

        $this->mediaManager->prepareMedia($entity);

        return true;
    }
972118
public function isValidEntity($entity) {
    if ($entity->getEntityTypeId() === 'mentions') {
      return TRUE;
    }

    // Special cases for comments and posts.
    $allowed_content_types = [
      'comment',
    ];
    if (in_array($entity->getEntityTypeId(), $allowed_content_types)) {
      $mentions = $this->getMentionsFromRelatedEntity($entity);
      if (!empty($mentions)) {
        return TRUE;
      }
    }
    return FALSE;
  }
974284
public function isEntityScheduled($entity)
    {
        $oid = spl_object_id($entity);

        return isset($this->entityInsertions[$oid])
            || isset($this->entityUpdates[$oid])
            || isset($this->entityDeletions[$oid]);
    }
171414
public function isRegisteredEntity($entity)
    {
        if (!is_string($entity)) {
            $entity = get_class($entity);
        }

        return array_key_exists($entity, $this->entityClasses);
    }
379026
public function post(EntityInterface $entity)
    {
        $pk = (string)TableRegistry::get($entity->source())->primaryKey();
        if (empty($this->_controller->request->data['comment']) ||
            $this->config('settings.visibility') !== 1 ||
            !$entity->has($pk)
        ) {
            return false;
        }

        $this->_controller->loadModel('Comment.Comments');
        $data = $this->_getRequestData($entity);
        $this->_controller->Comments->validator('commentValidation', $this->_createValidator());
        $comment = $this->_controller->Comments->newEntity($data, ['validate' => 'commentValidation']);
        $errors = $comment->errors();
        $errors = !empty($errors);

        if (!$errors) {
            $persist = true;
            $saved = true;
            $this->_controller->Comments->addBehavior('Tree', [
                'scope' => [
                    'entity_id' => $data['entity_id'],
                    'table_alias' => $data['table_alias'],
                ]
            ]);

            if ($this->config('settings.use_akismet')) {
                $newStatus = $this->_akismetStatus($data);
                $comment->set('status', $newStatus);

                if ($newStatus == 'spam' &&
                    $this->config('settings.akismet_action') != 'mark'
                ) {
                    $persist = false;
                }
            }

            if ($persist) {
                $saved = $this->_controller->Comments->save($comment);
            }

            if ($saved) {
                $this->_afterSave($comment);

                return true; // all OK
            } else {
                $errors = true;
            }
        }

        if ($errors) {
            $this->_setErrors($comment);
            $errorMessage = $this->config('errorMessage');
            if (is_callable($errorMessage)) {
                $errorMessage = $errorMessage($comment, $this->_controller);
            }
            $this->_controller->Flash->danger($errorMessage, ['key' => 'commentsForm']);
        }

        return false;
    }
180774
public function initialize(Entity\Entity $entity)
    {
        $this->setupContenttype($entity);
        $this->setupContainer($entity);
    }
818791
public function isGranted($action, $entity, array $parameters = array())
    {
        $entityType = defined(get_class($entity) . '::ENTITY_TYPE') ? $entity::ENTITY_TYPE : null;

        if (!is_null($entityType) && array_key_exists($entityType, $this->strategies) && $this->strategies[$entityType]->support($action)) {
            return  $this->strategies[$entityType]->isGranted($action, $entity, $parameters);
        }

        return true;
    }