How can I launch the executeSomething(sfWebRequest $request) in symfony? - plugins

I am new to Symfony 1.4
I have a plugin and inside the modules folder I have payment module, and for this, I have the lib folder and the templates folder. In lib I have the BasePaymentComponents.class.php class and in this class I have some functions called with the prefix executeSometing in this way:
public function executeSometing(sfWebRequest $request)
An for each execute I have a specific template in templates folder. The file structure is like that: _something1.php, _something2.php ...
My question is in what moment the executeSometing function from BasePaymentComponents.class.php is actually executed?
I created another template, named _something3.php and set for him the function:
public function executeSometing3(sfWebRequest $request)
actually is not launching the function. Why?

You are using components - you add components to a template - so to execute the Something method in the BasePayment component you would add the following to your template :
<?php include_component('BasePayment', 'something') ?>
Check the docs here -> Inside the view layer <- for more info

Related

Extbase view variable not getting

/**
* New post form
* #param \Vendor\My\Domain\Model\Post|null $newPost New post
* #return void
* #dontvalidate $newPost
*/
public function newAction(\Vendor\My\Domain\Model\Post $newPost = NULL) {
$this->view->assign('test', 'hello');
$this->view->assign('categoryList', $this->categoryRepository->findAllByBlog(0));
$this->view->assign('postObject', $newPost);
}
public function editAction() {
$this->view->assign('categoryList', $this->categoryRepository->findAllByBlog(0));
$postObject = $this->postRepository->findOneByUid($this->request->getArgument('id'));
$this->view->assign('postObject', $postObject);
}
this is my script and my problem is that I have a categoryList array, its is only getting in edit view. I want to use that category list on newaction. When I tried to foreach that array in new action view file it is getting empty. and i can get it after saving the postObject. Any idea about this particular problem? and variable test from newaction also not visible in the newAction Template file.
Am using Typo3 7.6.11
Declare arguments you want to receive, as arguments for your controller action. Reference this argument name correctly in Fluid templates when you build links to your controller action. Do not access arguments from the Request directly. Add correct PDPdoc comments for it, too.
Basically: do the correct thing with your arguments instead of bypassing the framework. This advise applies to anything you do in Extbase.
NB: New and Edit actions should never, ever share the same template (this further indicates you bypass the framework's expected behavior). Create and New, yes. But not New and Edit. If necessary, put the form fields in a partial and the form itself in separate templates so you can control the action building and object/object-name setup correctly.
If a $this->***Repository method returns NULL, it may be that the repository had no StoragePid defined.
Make sure both newAction and editAction have the same storagePid defined in TypoScript or your Backend Plugin Settings (Flexform).
The TypoScript for this would look something like this:
plugin.tx_extension.persistence.storagePid = 100

In magento 2 How to call phtml file in static block

I have created extension in magento 2 and i want to call content.phtml file from static block (from admin panel). My content template file location is
C:\xampp\htdocs\Magento2\app/code\Surya\Slider\view\frontend\templates\content.phtml
where, magento2 is my project folder, Surya is vendor and Slider is my extension name. I want to call content.phtml file on homepage through static block.
For that I have created one static block called as "slider". Also, i have created widget. But i want to call content.phtml file in static block.
try below code :
{{block class="Surya\Slider\Block\Slideshow" template="Surya_Slider::content.phtml"}}
You can try the following code -
{{block class="Surya\Slider\Block\Slideshow" template="Surya_Slider::content.phtml"}}
If you would like to call template block in CMS static Block or CMS Page in Magento 2, then you can simply write the following code:
The skeleton code to understand :
{{block class="<vendor_name>\<module_name>\Block\<module_name>" name="<your_block_name>" template="<vendor_name>_<module_name>::<tempate_directory>/content.phtml"}}
Exact code :
{{block class="Surya\Slider\Block\Slider" name="slider" template="Surya_Slider::content.phtml"}}

Typo3 Extension PHP View

Using the infos in this link:
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/8-Fluid/9-using-php-based-views.html
I try to create an action to output a JSON.
I have a normal controller with the list action:
public function listAction()
{
$storelocators = $this->storelocatorRepository->findAll();
$this->view->assign('storelocators', $storelocators);
}
And in ext/my_storelocator/Classes/View/Storelocator I have a class List.php:
<?
class Tx_MyStorelocator_View_Storelocator_List extends Tx_Extbase_MVC_View_AbstractView {
public function render() {
return 'Hello World';
}
}
All I get is:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be resolved for action "list" in class "My\MyStorelocator\Controller\StorelocatorController".
So I guess there is something wrong with the paths. Or where is the Problem?
Edit: Extensioninfos
Vendor: My
key: my_storelocator
controller: NOT SURE (I created it with the extension_builder so I guess my controllers name is Storelocator)
action: list
From my understanding a classname like Tx_MyStorelocator_View_Storelocator_List should be correct. But its not working
You will need to create an empty file for the HTML view for your controller, e.g. Resources/Private/Template/Storelocator/List.html, even if you do not plan to use the HTML view or if you just return the content yourself (which is perfectly fine).
The reason for this is simply technical limitation.
First of all, TYPO3 now has a built-in JSON view, described thoroughly here: https://usetypo3.com/json-view.html. It lets you easily define which properties you'd like to render.
The error message means that your Controller is still pointing to the TemplateView - because thats the error the TemplateView throws if it can't find the defined template file.
You can specify which view to use to render within your controller. You can either set a default view via the $defaultViewObjectName property, like so:
/**
* #var string
*/
protected $defaultViewObjectName = '\TYPO3\CMS\Fluid\View\TemplateView';
You can also set it from within the Controller inside initialization actions like so:
public function initializeExportPDFAction(){
$this->defaultViewObjectName = 'Vendor\Extension\View\FileTransferView';
}
(I have, however, not yet found a way to define the template from within actions, any tips in the comments would be appreciated)
Your path syntax is probably out of date. Instead of writing a render() function in Classes/View/Storelocator/List.php, try writing a listAction() function in a Classes/Controller/StorelocatorController.php file. Extension Builder should have created this file for you, if you made an aggregate model with the usual "list, create, edit ..." and such actions.
Review A journey through the Blog Example and the following chapter, Creating a first extension, for tips.
Keep in mind that there is a mismatch between the documentation and the Extension Builder generated PHP code files. Developing TYPO3 Extensions with Extbase and Fluid has some parts up to date, and other parts still using old syntax.

Is it possible to call include/require from a class object for the current file?

So here's my idea. I have a class that takes a file, checks for a specific snippet, str_replaces it, and returns it back. Kind of like how a simplified smarty works with tag replacement
so for example if my index.php looks like:
<?php
include('file.php');
....
?>
it becomes:
<?php
include($myClass->edit('file.php');
....
?>
That works fine. But instead of that, would it be possible to have the actual include() function replaced by my own?
making it:
<?php
$myClass->myinclude('file.php');
....
?>
The myinclude() function in my class would be:
public function myinclude ($file) {
include($this->edit('file.php'));
}
But it doesn't work, I assume because I can't call the include from within the class and expect it to return back to the calling index.php file.
Is there some trick around this?
include is not a function but a language construct. When your php is executed the contents of included file (or even php executable strings) are copied at the point of inclusion.

Zend Framework's Action helper doesn't use a ViewRenderer

I'm trying to execute an action from the view using the Action helper like but although the action is been executed the output isn't displayed.
Here's part of my .phtml file:
<div id="active-users">
<?php echo $this->action('active', 'Users') ?>
</div>
The action works like this:
class UsersController extends Zend_Controller_Action
{
function activeAction()
{
$model = new UsersModel();
$this->view->users = $model->getActiveUsers();
}
}
And there's another .phtml file that renders the list of users. The action works fine when called directly from /users/active but doesn't display anything when called from inside another .phtml file.
I've tracked the problem to the ViewRenderer not been available when called with action() helper... or at least not working as usual (automatically rendering the default .phtml file).
The content is displayed if I explicitly render the view inside the action but I need the ViewRender behaviour because I don't control the code of some of the actions I need to use.
Is there anyway to turn the ViewRenderer on while using the action() view helper? I'm open to replace the action() view helper if needed.
I forgot: I'm using PHP 5.2.8, Zend Framework 1.7.5, Apache 2.2 on Windows Vista.
Thanks
i think you should asign the active users from the controller or if you want you can use singleton on the models an use the directly in the views
$this->view = UsersModel::instance()->getActiveUsers();
Are you using _forward() o redirect on your action? Actions that result in a _forward() or redirect are considered invalid, and will return an empty string.
Update: I test it, and it works, try writing 'users' instead of 'Users' in the controllers param.
<div id="active-users">
<?php echo $this->action('active', 'users') ?>
</div>