Where should I define global functions in ExtJS 5 MVVM? 1 - extjs5

I need to create/call a specific class to have utilities functions for my app.
This exactly correspond to this topic:
Where should I define global functions in ExtJS 4 MVC?
But this, do not work with ExtJS 5. So I would like to know how make with ExtJS 5.
Thank you for your help.

Create a singleton class with all these functions, give the class an alternate name like Utils. Require the class in the main application and simply use Utils.method

Related

Angular 6 - store global variables and data

I've wondered where is the best place to store shared data and global vars in Angular 6.
I know I can set them on a service that can be injected to any of my components, but I'm sure there's a better practice...
Thanks in advance!
I am not sure it is the best practice, but if you want variable to be available in all places without any injections, you can use the global "window" object. it is not an angular way but if your project work with external libraries that didn't written in angular it can help you to communicate with it easily.
for example, you can type window.x = "something" to create new variable in the window object.

CakePHP 3 - additional Controller namespaces

Is it possible to force CakePHP 3 to read controllers also from other directories, not only default one, e.g. App\Controller\ApiController folder?
You can use routing prefixes for having controller in other namespaces, that would be the built-in solution:
http://book.cakephp.org/3.0/en/development/routing.html#prefix-routing
The other solution is to implement your own ControllerFactoryFilter and based on any arbitrary rules, find the controller in another namespace. This is the original implementation of the factory:
https://github.com/cakephp/cakephp/blob/3.0/src/Routing/Filter/ControllerFactoryFilter.php

Laravel Equivalent of passing variables to functions in codeigniter

I am using CodeIgniter from 2 years and i am trying to move to Laravel and I saw many tutorials of how to use Laravel but i couldn't find any answers to how to pass variables to functions using the URL and without using routes like in CodeIgniter if i called this link
site.com/users/edit/12.
I would be calling the users controller , the edit function and passing a variable of value 12
how can i do the same in Laravel without using routes for every single function or using query strings which will make the URL ugly?
Here is an example.Hope that it will be helpful.......
route.php
Route::controller('users','UsersController');
UsersController.php
class UsersController extends BaseController
{
public function getEdit($value)
{
echo $value;
}
}
url
site.com/users/edit/12
output
12
In Laravel - 3 you may do it using something like this:
Route::controller(Controller::detect());
But in later versions it's not available and you should explicitly declare the routes. Actually it's better to declare routes explicitly and this approach has many benefits too. This is a common problem that happens to developers who migrates from CodeIgniter but later they get motivated and if you use this you'll love this for sure.
You may read this article by Phil Sturgeon who was the man behind the CodeIgniter framework, he discussed about it's down sides of this (automatic routing).
If you are using Laravel - 4 then check the Controllers Manual, specially check out the RESTful and Resourceful controllers section, it may attract you but be familiar with explicit route declaration first.

How to reference to database from a CakePHP library

I've created a library class file in my CakePHP 2.0 app. It's a single PHP class called emailManager Which exists within a folder emailManager within CakePHP's libaray folder. I would love to know what is the simplest way to reference the database from this library class.
I would love to be able to do something like $this->AppModel->query("SELECT * FROM some_table_in_my_db"), that way I do not have to track DB configurations in separate places, but I'm not sure how to achieve this.
Also, I feel it is important to mention that the tables I am working with do not adhere to CakePHP table naming convention. They predate our use of CakePHP and so I cannot change my tables to fit CakePHP's model format. this is why I want generic database access via something like query
EDIT: I have constructed a temporary solution, but I know a better one is possible.
I have a model in my cake app called MySimpleConstuct and then in the library file I include the MySimpleConstruct Model as followed:
// import this model
$this->GivenModel = ClassRegistry::init('MySimpleConstruct');
$this->GivenModel = new MySimpleConstruct();
// Then it is possible to do as followed:
$table_data = $this->GivenModel->query('SELECT * FROM like_some_table_dude' WHERE 1);
This is not ideal so I still searching for a better solution.
Any help would be greatly appreciated.
#John Galt, I suppose it's not an exact duplicate but it is very similar and the resolution does appear to apply to your situation very directly.
The other technique you could consider using would be to instantiate the Library in the controller and than give it a reference of the model.
class TestController extends AppController {
function index(){
App::uses('TheLibrary', 'Lib');
$obj = new TheLibrary();
$obj->GivenModel = &$this->GivenModel;
}
}
-EDIT-
And then within the library you've written do something like this.
class TheLibrary {
var $GivenModel = null;
function some_query(){
return $this->GivenModel->query('SELECT * FROM like_some_table_dude WHERE 1');
}
}
The first code snippet is of the Controller instantiating your library and then giving the library a reference to the Model as the property GivenModel. The "&" symbol makes the assignment a reference (see How does the '&' symbol in PHP affect the outcome?). The second code snippet is of a sample of how the library would use that property.
I do understand that you are trying to use a model from the library and that is what the solution you have in your edit and my proposed solution both do. However I will note again that this is not proper MVC convention and you should reconsider how you are using Libraries.

Flash: pure actionscript project: ToolTipManager class not registered?

I have a pure ActionScript 3 project that I build using the open source command-line compiler. I'm trying to add tooltips to my controls using mx.managers.ToolTipManager.
The code compiles without issues, but when I try to add the tooltip I get the following exception:
No class registered for interface 'mx.managers::IToolTipManager2'
I experimented with trying to register a class against that interface manually, something like:
var toolTipManagerImpl:Object = ApplicationDomain.currentDomain.getDefinition('mx.managers::ToolTipManagerImpl');
Singleton.registerClass("mx.managers::IToolTipManager2", Class( toolTipManagerImpl ) );
...but that leaves me with a null ToolTipManager reference.
Any ideas what I have to do to use the ToolTipManager in this environment?
Thanks in advance.
The SWCs are not n the build path and, what is more important: it will most likely not work because the whole framework is missing, which the components rely on.