PHP code example of maslosoft / signals

1. Go to this page and download the library: Download maslosoft/signals library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

maslosoft / signals example snippets


$signal = new Maslosoft\Signals\Signal();
$signal->runtimePath = RUNTIME_PATH;
$signal->paths = [
	MODELS_PATH
];
$signal->init();

$signal = new Maslosoft\Signals\Signal();
(new Maslosoft\Signals\Utility($signal))->generate();

namespace MyNamespace\Signals;

class AccountMenuItems extends AdminMenuItems
{
	public $item = [];
}

namespace Maslosoft\Ilmatar\Modules;

class MyModule
{
	/**
	 * @SlotFor(MyNamespace\Signals\AccountMenuItems)
	 */
	public function reactOnAccountMenu(MyNamespace\Signals\AccountMenuItems $signal)
	{
		$signal->item = [
			'url' => '/content/myBlog',
			'label' => 'My blog'
		];
	}
}

$signal = new Maslosoft\Signals\Signal();
$result = $signal->emit(new AdminMenuItems());

echo $result[0]->item[0]['label']; // My blog