setOperation example

$entity = $this->getMockForAbstractClass('Drupal\Core\Entity\EntityBase', [[]$definition['entity_type']], '', TRUE, TRUE, TRUE, ['getEntityType', 'bundle']);

    $entity->expects($this->any())
      ->method('getEntityType')
      ->willReturn($this->entityType);
    $entity->expects($this->any())
      ->method('bundle')
      ->willReturn($definition['bundle']);

    $this->entityForm->setEntity($entity);
    $this->entityForm->setOperation($definition['operation']);

    $this->assertSame($expected$this->entityForm->getFormId());
  }

  /** * Provides test data for testFormId(). */
  public function providerTestFormIds() {
    return [
      [
        'node_article_form',
        [
public function getFormObject($entity_type_id$operation) {
    if (!$class = $this->getDefinition($entity_type_id, TRUE)->getFormClass($operation)) {
      throw new InvalidPluginDefinitionException($entity_type_idsprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type_id$operation));
    }

    $form_object = $this->classResolver->getInstanceFromDefinition($class);

    return $form_object
      ->setStringTranslation($this->stringTranslation)
      ->setModuleHandler($this->moduleHandler)
      ->setEntityTypeManager($this)
      ->setOperation($operation);
  }

  /** * {@inheritdoc} */
  public function getRouteProviders($entity_type_id) {
    if (!isset($this->handlers['route_provider'][$entity_type_id])) {
      $route_provider_classes = $this->getDefinition($entity_type_id, TRUE)->getRouteProviderClasses();

      foreach ($route_provider_classes as $type => $class) {
        $this->handlers['route_provider'][$entity_type_id][$type] = $this->createHandlerInstance($class$this->getDefinition($entity_type_id));
      }
Home | Imprint | This part of the site doesn't use cookies.