Skip to content
Snippets Groups Projects

1.x

Merged Bartek Jaskulski requested to merge 1.x into review
  • Basic implementation of plugin initializer
  • docs: improve documentation
  • docs: improve API method documentation
  • chore: improve composer package definition and readme
  • feat(wip): allow private hooks calls
  • improve into wp-hook and some additional unfinished things
  • feat: moving toward actual implementation
  • refactor: hookable driver should belong to separate package
  • refactor: HookProvider also belongs to another package
  • refactor: remove PluginHeaderData
  • feat: add VERY simple command to cache plugin data
  • refactor: rename header parser implementation
  • refactor: simplify package
  • refactor: remove unused tests
  • chore: add static analysis
  • feat: add initial bindings for wp-builder compatibility
  • chore: add editorconfig
  • fix: passthrough container definitions argument
  • fix: use absolute cache path
  • fix: don't use hook and global variable
  • refactor: remove method, which can be replaced with get_path
  • refactor: reorder definition loading, change config key name
  • fix: correct cache path
  • feat: add hook driver backward compatible with wp-builder
  • fix: throw exception on failed load
  • feat: add check for optional package
  • chore: add config files
  • feat: large rework, needs followup

Merge request reports

Approval is optional

Merged by Marcin KolankoMarcin Kolanko 11 months ago (Jul 16, 2024 12:57pm UTC)

Merge details

  • Changes merged into review with f5c07186.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
bin/wpinit 0 → 100755
1 #!/usr/bin/env php
2 <?php
3
4 use WPDesk\Init\Util\PhpFileDumper;
5
6 include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
7
8 $filename = $argv[1] ?? null;
9
10 $parser = new \WPDesk\Init\Plugin\DefaultHeaderParser();
11
12 $data = $parser->parse( $filename );
  • bin/wpinit 0 → 100755
    1 #!/usr/bin/env php
    2 <?php
    3
    4 use WPDesk\Init\Util\PhpFileDumper;
    5
    6 include $_composer_autoload_path ?? __DIR__ . '/../vendor/autoload.php';
    7
    8 $filename = $argv[1] ?? null;
    9
    10 $parser = new \WPDesk\Init\Plugin\DefaultHeaderParser();
    11
    12 $data = $parser->parse( $filename );
    13
    14 $dumper = new PhpFileDumper();
    15 $dumper->dump( $parser->parse( $filename ), $argv[2] );
  • 11
    12 class CallableBinder implements Binder {
    13
    14 /** @var ContainerInterface */
    15 private $container;
    16
    17 public function __construct( ContainerInterface $c ) {
    18 $this->container = $c;
    19 }
    20
    21 public function can_bind( Definition $def ): bool {
    22 return $def instanceof CallableDefinition;
    23 }
    24
    25 public function bind( Definition $def ): void {
    26 if ( $def instanceof CallableDefinition ) {
  • 11
    12 /** @var ?string */
    13 private $hook;
    14
    15 /** @var callable */
    16 private $callable;
    17
    18 public function __construct(
    19 callable $callable,
    20 ?string $hook = null,
    21 ) {
    22 $this->callable = $callable;
    23 $this->hook = $hook;
    24 }
    25
    26 public function hook(): ?string {
    • wiem że to bzdet, ale z nazwy metody hook, nie wynika czy ta metoda służy do wykonywania hooków, czy też pobierania/zapisywania nazwy hooka.

      podobne odczucia mam z metodą value

    • najchętniej użyłbym public readonly :wink: still, po prostu nie lubię nawalania wszędzie get_, is_, etc. dlatego, kiedy kontekst tego nie zaburza, staram się zawężać do samego rzeczownika.

      Anyway, jeśli Ci to nie pasuje, feel free to change

    • Please register or sign in to reply
  • 15 private $container;
    16
    17 public function __construct( ContainerInterface $c ) {
    18 $this->container = $c;
    19 }
    20
    21 public function can_bind( Definition $def ): bool {
    22 return $def instanceof CallableDefinition;
    23 }
    24
    25 public function bind( Definition $def ): void {
    26 if ( $def instanceof CallableDefinition ) {
    27 $ref = new \ReflectionFunction( $def->value() );
    28 $parameters = [];
    29 foreach ( $ref->getParameters() as $ref_param ) {
    30 $parameters[] = $this->container->get( $ref_param->getType()->getName() );
  • 13 private $bindings;
    14
    15 /** @var DefinitionFactory */
    16 private $factory;
    17
    18 public function __construct( array $bindings, ?DefinitionFactory $factory = null) {
    19 $this->bindings = $bindings;
    20 $this->factory = $factory ?? new DefinitionFactory();
    21 }
    22
    23 public function load(): iterable {
    24 yield from $this->normalize( $this->bindings );
    25 }
    26
    27 private function normalize( $bindings ) {
    28 $normalized = [];
  • 12 /** @var array */
    13 private $bindings;
    14
    15 /** @var DefinitionFactory */
    16 private $factory;
    17
    18 public function __construct( array $bindings, ?DefinitionFactory $factory = null) {
    19 $this->bindings = $bindings;
    20 $this->factory = $factory ?? new DefinitionFactory();
    21 }
    22
    23 public function load(): iterable {
    24 yield from $this->normalize( $this->bindings );
    25 }
    26
    27 private function normalize( $bindings ) {
  • 25 }
    26
    27 private function normalize( $bindings ) {
    28 $normalized = [];
    29 foreach ( $bindings as $key => $value ) {
    30 if ( is_array( $value ) ) {
    31 foreach ( $value as $unit ) {
    32 yield $this->create( $unit, $key );
    33 }
    34 } else {
    35 yield $this->create( $value, $key );
    36 }
    37 }
    38 }
    39
    40 private function create( $value, $hook ) {
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading