I'm have issues trying to get inline tags to methods working, with phpDocumentor version 2.0.0a12. Using the sample code below, no matter what I try (eg /global/foo::bar(), foo::bar, foo::bar() etc) in the {#link parameter} the text gets printed out everytime, instead of parsed as an html anchor tag.
Is anybody else seeing this?
<?php
/**
* File docblock thingy
*/
/**
* Class docblock thingy
*/
class foo{
/**
* Description for bar {#link http://google.ie click for google} this is the inline link
* #return boolean Default true
*/
public function bar(){
return true;
}
/**
* Description for baz {#link foo::bar()}
* #return boolean Default false
*/
public function baz(){
return false;
}
}
Maybe I'm missing a config parameter? The config using for above is:
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
<parser>
<target>.</target>
<default-package-name>Foo</default-package-name>
<parseprivate>on</parseprivate>
</parser>
<transformer>
<target>docs</target>
</transformer>
<files>
<directory>.</directory>
</files>
</phpdoc>
This could be considered a duplicate of PHPDoc inline {#link} (and Netbeans) but I dont' think so because I'm calling phpdoc from command line (not using and IDE).
Any help seriously appreciated ;)
Inline {#link} is not yet implemented in v2 -- http://phpdoc.org/docs/latest/references/phpdoc/tags/link.html
Related
I've tried a lot of suggestions here but it seems like nothing works for me. I am trying to listen to event 'checkout_onepage_controller_success_action'. I am trying to set the order status to 'complete' upon checkout (for now, I commented out that part).
As you may see below (inside the execute method), I am trying to print out the order object then exit. But when testing, nothing happens. No print out, no error message. Nothing...
I ran the following commands before testing:
bin/magento setup:upgrade, bin/magento setup:di:compile, bin/magento cache:clean
I also tried listening to event sales_order_place_after. I also got nothing...
app/code/[company]/[module]/etc/frontend/events.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_onepage_controller_success_action">
<observer instance="[company]\[module]\Observer\CheckoutSuccessObserver" name="checkout_onepage_controller_success_action_observer"/>
</event>
</config>
app/code/[company]/[module]/Observer/CheckoutSuccessObserver.php
<?php
namespace [company]\[module]\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
/**
* Class CheckoutSuccessObserver
*
* #package [company]\[module]\Observer
*/
class CheckoutSuccessObserver implements ObserverInterface
{
/**
* Execute observer
*
* #param \Magento\Framework\Event\Observer $observer
* #return void
*/
public function execute(Observer $observer)
{
$order = $observer->getEvent()->getOrder();
print_r($order); exit;
//$order = $observer->getEvent()->getOrder();
//$order_id = $order->getIncrementId();
//$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
//$order->setData('state', "complete");
//$order->setStatus("complete");
//$history = $order->addStatusHistoryComment('Order was set to complete by our automation tool.', false);
//$history->setIsCustomerNotified(null);
//$order->save();
}
}
Your sample code looks ok.
Did you enable your custom module? Check it using bin/magento module:status [company]_[module]
Try also to clear the project's directories: https://devdocs.magento.com/guides/v2.3/howdoi/php/php_clear-dirs.html.
Oke, so I have the following use case. On some of my entities I use a file entity for example with the organization logo.
Now I want users to post either a link (I will then async get the file) or a base64 has of the file. But when the user does a get I want to present an JSON representation of the file entity (that also includes size, a thumbnail link etc).
The current setup that I have is two different properties on my entity, one for reading and one for posting with different logic. And then an event listener that handels the logic. That’s all fine and all but it causes the user to post a postLogo property in their json file, I would hower like them to post to a logo property in their json file.
Is there an annotation that I can use (for example name on ApiProperty) to achieve this or do I need to override the serializer?
/**
* #var File The logo of this organisation
*
* #ORM\ManyToOne(targetEntity="File")
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="#/components/schemas/File"
* }
* }
* )
* #Groups({"read"})
*/
public $logo;
/**
* #var string The logo of this organisation, a logo can iether be posted as a valid url to that logo or a base64 reprecentation of that logo.
*
* #ApiProperty(
* attributes={
* "openapi_context"={
* "type"="url or base64"
* }
* }
* )
* #Groups({"write"})
*/
public $postLogo;
You can add a setter with a SerializedName annotation. Something like this should work
/**
* #Groups({"write"})
* #SerializedName("logo")
*
*/
public function setPostLogo($value)
{
$this->postLogo = $value;
}
I have following action:
http://localhost/admin/catalog/product_attribute/edit/attribute_id/135/key/…/
I would like to do some extra things with attribute after saving.
I have created and registered custom plugin in Vendor/Module/Plugin/Model/ResourceModel/Attribute/Save.php with following content:
class Save
{
/**
* #var Config
*/
protected $config;
/**
* #param Config $config
*/
public function __construct(Config $config, TypeListInterface $typeList)
{
$this->config = $config;
}
/**
*
* #param Attribute $subject
* #param Attribute $result
* #return Attribute $result
*
*/
public function afterSave(Attribute $subject, Attribute $result)
{
# Do something
}
}
I have also added following entry to di.xml:
<type name="Magento\Catalog\Model\ResourceModel\Attribute">
<plugin name="do_stuff_after_attribute_save" type="Vendor\Module\Plugin\Model\ResourceModel\Attribute\Save" />
</type>
But the plugin seems not to work. Even if I die('somenthing'); or try to log to file, the code is not executed after saving the attribute.
Maybe I am trying to overwrite wrong method?
You could follow the points below:
You should use di.xml in the adminhtml folder as it is a backend issue.
You should override the execute method of this Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save controller class.
File: app/code/Milandev/Testplugin/etc/adminhtml/di.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save">
<plugin disabled="false" name="Milandev_Admin_Product_Attribute_Save" sortOrder="10" type="Milandev\Testplugin\Plugin\Catalog\Controller\Adminhtml\Product\Attribute\Save"/>
</type>
</config>
File: app/code/Milandev/Testplugin/Plugin/Catalog/Controller/Adminhtml/Product/Attribute/Save.php
<?php
namespace Milandev\Testplugin\Plugin\Catalog\Controller\Adminhtml\Product\Attribute;
class Save
{
public function afterExecute(
\Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save $subject,
$result
) {
die('hello world!');
//Your plugin code
}
}
I ran into the same issue some time ago. Turned out that there was another plugin installed which tried to handle the exact same class and property. After adding the sortOrder attribute on both di.xml files, with of course a different value for both, everything worked fine.
Try to make sure that your plugin is applied and all other plugins return expected values.
Go to generated/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute/Interceptor.php (if it's already generated). If not, just enable developer mode (it will be generated automatically) or run php bin/magento setup:di:compile for production mode.
Look for afterSave() method and print the list of available plugins. E.g.
/**
* {#inheritdoc}
*/
public function afterSave()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'afterSave');
echo "<pre>";
print_r($pluginInfo);
die;
if (!$pluginInfo) {
return parent::afterSave();
} else {
return $this->___callPlugins('afterSave', func_get_args(), $pluginInfo);
}
}
Then you should see the list of enabled plugins (in your case it might be save_swatches_option_params ). Just look for matches in the code and make sure all of them return EXPECTED results. By default, "after" plugins should return the same $result as the original method does. Otherwise, the next plugins will not work correctly, like in your case.
I created a module (extends Mage_Core_Model_Abstract) and an admin controller.
When I run this module online translations are going right.
When I run this module as cronjob, everything goes allright but translations are not done, I specified translation file in config.xml in as well frontend as adminhtml.
What I am doing wrong?
I see this is a very old question. I've posted here to future reference and others.
Quick and dirty solution
// Fix unitialized translator
Mage::app()->getTranslator()->init('frontend', true);
just after
$initialEnvironmentInfo = $appEmulation>startEnvironmentEmulation($storeId);
for instance. Or in a foreach loop of your own, which is called via cron/admin. Since you're talking about crons, I assume that you know what you are doing.
The real problem
In Magento 1.9 in Mage_Core_Model_App_Emulation (in app/code/core/Mage/Core/Model/App/Emulation.php), there's this function:
/**
* Apply locale of the specified store
*
* #param integer $storeId
* #param string $area
*
* #return string initial locale code
*/
protected function _emulateLocale($storeId, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
{
$initialLocaleCode = $this->_app->getLocale()->getLocaleCode();
$newLocaleCode = $this->_getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId);
if ($initialLocaleCode != $newLocaleCode) {
$this->_app->getLocale()->setLocaleCode($newLocaleCode);
$this->_factory->getSingleton('core/translate')->setLocale($newLocaleCode)->init($area, true);
}
return $initialLocaleCode;
}
The $initialLocaleCode != $newLocaleCode seems to be the issue here. When iteration orders/customers/subscribers/*, the locale could stay the same, which then prevents executing the code in the statement. And the locale is thus not set in the Translator (Mage::app()->getTranslator()).
We've yet to fix the issue, but you could change if ($initialLocaleCode != $newLocaleCode) { to if (true) { straight in the core source. Off course, this is ugly. I suggest something like extending the class and then :
/**
* Apply locale of the specified store. Extended
* to fix Magento's uninitialized translator.
*
* #see http://stackoverflow.com/questions/19940733/magento-translations-ok-in-online-program-but-not-run-as-cronjob#
* #param integer $storeId
* #param string $area
*
* #return string initial locale code
*/
protected function _emulateLocale($storeId, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
{
$initialLocaleCode = $this->_app->getLocale()->getLocaleCode();
$newLocaleCode = $this->_getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId);
$this->_app
->getLocale()
->setLocaleCode($newLocaleCode);
$this->_factory
->getSingleton('core/translate')
->setLocale($newLocaleCode)
->init($area, true);
return $initialLocaleCode;
}
Magento 2
I guess the developers became aware it was borked and they changed the code in Magento 2. The _emulateLocale() function is gone all together and they added this line to the startEnvironmentEmulation() function, without any conditional around it:
$this->_localeResolver->setLocale($newLocaleCode);
It's a bug even with CE 1.9.0.1!
See what I've done about it:
https://magento.stackexchange.com/questions/25612/cron-job-template-block-not-being-translated-but-testobserver-is/25920#25920
I try to make use of code assistant in Aptana.
It seems that it is not working with js self written code, or I'm using it the wrong way.
I'm working with Aptana Studio 3, build: 3.2.2.201208201020
I comment my javascript like so:
/**
Simple utilities like alert/info/error windows etc.
#constructor
#param object params - set of key:value properties
*/
function SomeClass(params)
{
/**
* #var some description
*/
this.messages = [];
/**
* My function
*
* #param string some_param - some description
*/
this.somefunction = function(some_param)
{
//some code
}
}
Now when I type this. in SomeClass block a popup shows and i can find messages and somefunction but it say that both have no description.
When I'm in this.somefunction section I get proposals for global variables like window.location but no help for this. nor for SomeClass
I'm using this comment style in php and it works like a charm.
What am I doing wrong? This JS comment style was working in my previous eclipse - helios.