- 🇮🇳India himanshu_jhaloya Indore
using this way can do
basic/basic.services.ymlservices:
basic.basic_hero_articles:
class: Drupal\basic\BasicArticleServicebasic.basic_recipes:
class: Drupal\basic\BasicRecipeService
arguments: ['@entity.manager']...
lightning-8/modules/custom/basic/src/BasicRecipeService.php
<?php
namespace Drupal\basic;
use Drupal\Core\Entity\EntityManager;
/**
* Our basic recipes service
*/
class BasicRecipeService {private $entityQuery;
private $entityManager;public function __construct(EntityManager $entityManager) {
$this->entityManager = $entityManager;
}/**
* Methood for getting the recipes
*/
public function getRecipes() {
$recipesNids = $this->entityQuery->get('node')->condition('type', 'recipe')->execute();
return $this->entityManager->getStorage('node')->loadMultiple($recipesNids);
}
} - Issue was unassigned.
- Status changed to Needs review
about 2 years ago 6:36am 16 February 2023 - Status changed to Needs work
about 2 years ago 6:42pm 19 February 2023 - 🇺🇸United States smustgrave
Not sure what's there to review in #14? Are you asking how dependency injection works?
Adding a new service or updating one will require a change record just FYI.
- Assigned to roshni27
- Issue was unassigned.
- Status changed to Needs review
over 1 year ago 1:31pm 14 July 2023 - last update
over 1 year ago Custom Commands Failed - Status changed to Needs work
over 1 year ago 1:54pm 14 July 2023 - 🇺🇸United States smustgrave
Will need a trigger_error for the new parameter.
Also please don't assign tickets to yourself unless a maintainer. A simple comment is enough.
- 🇮🇹Italy apaderno Brescia, 🇮🇹
+ /** + * Creates an instance of this class. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container to resolve services. + * + * @return static + * The instance of this class. + */ + public static function create(ContainerInterface $container) {
The documentation comment for methods defined in an interface does not need to give that information, since it would repeat the documentation comment present in the interface.
/** * Add the next entity base table. * - * For example, when building the SQL query for + * For example, when building the SQL query for. * @code * condition('uid.entity.name', 'foo', 'CONTAINS') * @endcode
Since that comment is changed, it would be better to change it as:
/** * Add the next entity base table. * * For example, this adds the users table. * @code * condition('uid.entity.name', 'foo', 'CONTAINS') * @endcode * * @param \Drupal\Core\Entity\EntityType $entity_type * The entity type being joined, in the above example, User. * @param string $table * This is the table being joined, in the above example, {users}. * @param string $sql_column * This is the SQL column in the existing table being joined to. * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $field_storage * The field storage definition for the field referencing this column. * * @return string * The alias of the next entity table joined in. */