The actual action method of a dashboard controller
541734
def destroy
      @resource = model.find(params[:id])
      authorize @resource

      @resource_title = t(_resource_title.singularize)

      before_destroy_hook(@resource)
      @resource.destroy

      return if _override_views.include? :destroy
      render 'faalis/dashboard/resource/destroy'
    end
1360249
def controller_callback(which, type, axis, value, button)
      # All controller events
      @events[:controller].each do |id, e|
        e.call(ControllerEvent.new(which, type, axis, value, button))
      end

      case type
      # When controller axis motion, like analog sticks
      when :axis
        @events[:controller_axis].each do |id, e|
          e.call(ControllerAxisEvent.new(which, axis, value))
        end
      # When controller button is pressed
      when :button_down
        @events[:controller_button_down].each do |id, e|
          e.call(ControllerButtonEvent.new(which, button))
        end
      # When controller button is released
      when :button_up
        @events[:controller_button_up].each do |id, e|
          e.call(ControllerButtonEvent.new(which, button))
        end
      end
    end
915245
private function runAction()
    {
        // Get URL
        $url = $this->request->url();

        // Get route action
        $action = $this->router->getAction($url);

        // Perform the filter
        if ($action['filter']) {
            $filter = $this->router->performFilter($action['filter']);
        }

        // Check if the controller exists
        if (!isset($action) || !is_string($action['class']) || !class_exists($action['class'])) {
            throw new \Exception('Controller not found', 404);
        }

        // Create the required controller
        $controller = $this->make($action['class']);

        // Execute the required method and return the response
        return $this->response->output(call_user_func_array([$controller, $action['method']], $action['params']? : []));
    }
1352708
public function dashboard()
    {
        //if the dev has chosen to use a dashboard
        if (config('administrator.use_dashboard')) {
            //set the layout dashboard
            $this->layout->dashboard = true;

            //set the layout content
            $this->layout->content = view(config('administrator.dashboard_view'));

            return $this->layout;
        }
        //else we should redirect to the menu item
        else {
            $configFactory = app('admin_config_factory');
            $home          = config('administrator.home_page');

            //first try to find it if it's a model config item
            $config = $configFactory->make($home);

            if (!$config) {
                throw new \InvalidArgumentException('Administrator: '.trans('administrator::administrator.valid_home_page'));
            } elseif ($config->getType() === 'model') {
                return redirect()->route('admin_index', array($config->getOption('name')));
            } elseif ($config->getType() === 'settings') {
                return redirect()->route('admin_settings', array($config->getOption('name')));
            }
        }
    }
269035
private function analyseAction($controller) {
        $urlParam = explode('-', $controller);
        switch (count($urlParam)) {
            case 0:
                break;
            case 1:
                $this->controller = $urlParam[0];
                break;
            case 2:
                $this->controller = $urlParam[0];
                $_REQUEST['_1'] = $_GET['_1'] = $urlParam[1];
                break;
            default:
                $this->controller = $urlParam[0];
                foreach ($urlParam as $k => $v) {
                    if ($k === 0) {
                        continue;
                    }
                    $_REQUEST['_' . $k] = $_GET['_' . $k] = $v;
                }
                break;
        }
    }
1182877
public function dashboardAction()
    {
        /* @var $request \Zend\Http\Request */
        $request     = $this->getRequest();
        $params      = $request->getQuery();
        $isRecruiter = $this->Acl()->isRole(User::ROLE_RECRUITER);

        if ($isRecruiter) {
            $params->set('by', 'me');
        }

        $paginator = $this->paginator('Jobs/Job');

        return [
            'script' => 'jobs/index/dashboard',
            'type'   => $this->params('type'),
            'myJobs' => $this->jobRepository,
            'jobs'   => $paginator
        ];
    }
355042
function(action, thisp) {
		var res;
		if (this.observes) {
			if (++this._suspend === 1) {
				this._connect(false);
			}
		}
		if (gui.Type.isFunction(action)) {
			res = action.call(thisp);
		}
		if (this.observes) {
			this.resume();
		}
		return res;
	}
1218843
function getDashboardOperations(self) {
	var curatedDevice = self;

	// Object that stores the registered listeners.  When there are
	// no listeners, the dashboard data collection should be stopped.
	var dashboardListeners = {};

	// Object that caches the data.
	this.dataCache = {};

	// Function that adds a data listener.
	function addListener(uid) {
		var addedListener = false;
		if(typeof(dashboardListeners[uid]) === 'undefined') {
			dashboardListeners[uid] = {
				'startTime': new Date(),
				'numIterations': 0,
				'uid': uid,
				'numStarts': 1,
			};
			addedListener = true;
		} else {
			// Don't add the listener.
			dashboardListeners[uid].numStarts += 1;
		}
		return addedListener;
	}

	// Function that removes a data listener.  
	function removeListener(uid) {
		var removedListener = false;
		if(typeof(dashboardListeners[uid]) !== 'undefined') {
			dashboardListeners[uid] = undefined;
			delete dashboardListeners[uid];
			removedListener = true;
		}
		return removedListener;
	}

	// Function that gets the number of listeners.
	function getNumListeners() {
		return Object.keys(dashboardListeners).length;
	}

	// This is a test function that just prooves "basic signs of life".
	this.testFunc = function() {
		var defered = q.defer();
		debugDTF("In Dashboard testFunc",
			self.savedAttributes.productType,
			self.savedAttributes.serialNumber,
			self.savedAttributes.serialNumber
		);
		var info = {
			'pt': self.savedAttributes.productType,
			'sn': self.savedAttributes.serialNumber,
		};
		defered.resolve(info);
		return defered.promise;
	};

	// variable that stores the dataCollector
	var dataCollector;

	// Function that handles the data collection "data" events.  This
	// data is the data returned by the read-commands that are performed.
	// This data still needs to be interpreted saved, cached, and organized
	// into "channels".
	// Maybe?? The dashboard_data_collector has logic for each of the devices.
	// This logic should probably be put there?
	function dataCollectorHandler(data) {
		// debugDDC('New data', data['FIO0']);
		var diffObj = _.diff(data, self.dataCache);

		// console.log('Data Difference - diff', diffObj);
		// Clean the object to get rid of empty results.
		diffObj = _.pickBy(diffObj, function(value, key) {
			return Object.keys(value).length > 0;
		});

		var numKeys = Object.keys(data);
		var numNewKeys = Object.keys(diffObj);
		// console.log('Num Keys for new data', numKeys, numNewKeys);
		// console.log('Data Difference - pickBy', diffObj);
		self.dataCache = data;

		self.emit(device_events.DASHBOARD_DATA_UPDATE, diffObj);
	}

	// Function that creates the "bundle" that is built-up and passed between
	// the steps that perform the "start" method.
	function createStartBundle(uid) {
		// Create and define the bundle object.
		return {
			'uid': uid,
			'data': {},
		};
	}

	// This function starts the data collector and registers event listeners.
	function innerStart (bundle) {
		var defered = q.defer();

		// Device Type is either T4, T5, or T7
		var deviceType = self.savedAttributes.deviceTypeName;

		// Save the created data collector object
		dataCollector = new dashboard_data_collector.create(deviceType);

		// Listen to only the next 'data' event emitted by the dataCollector.
		dataCollector.once('data', function(data) {
			debugDStart('dev_cur-dash_ops: First bit of data!');

			// Listen to future data.
			dataCollector.on('data', dataCollectorHandler);

			// Save the data to the data cache.
			self.dataCache = data;
			bundle.data = data;

			// Declare the innerStart function to be finished.
			defered.resolve(bundle);
		});

		// Start the data collector.
		dataCollector.start(self);

		return defered.promise;
	}

	/*
	 * This function starts the dashboard-ops procedure and registers a listener.
	 * This function returns data required to initialize the dashboard page.  If
	 * the listener already exists then its uid isn't added (since it is already
	 * there).
	*/
	this.start = function(uid) {
		var defered = q.defer();
		var addedListener = addListener(uid);
		var numListeners = getNumListeners();
		var bundle = createStartBundle(uid);

		function onSuccess(rBundle) {
			defered.resolve(rBundle);
		}
		function onError(rBundle) {
			defered.resolve(rBundle);
		}

		if(addedListener && (numListeners == 1)) {
			// We need to start the dashboard-service and we need to return 
			// the current state of all of the channels.
			innerStart(bundle)
			.then(onSuccess, onError);
		} else {
			// We don't need to start the dashboard-service.  We just need to
			// return the current state of all of the channels.
			onSuccess(bundle);
		}
		return defered.promise;
	};

	/*
	 * These functions "pause" and "resume" the data-reporting
	 */
	this.pauseReporting = function(){};
	this.resumeReporting = function(){};

	/*
	 * These functions "pause" and "resume" the DAQ loop collecting data from
	 * the device.
	 */
	this.pauseCollecting = function(){};
	this.resumeCollecting = function(){};


	function createStopBundle(uid) {
		return {
			'uid': uid,
			'isStopped': false,
		};
	}
	function innerStop(bundle) {
		var defered = q.defer();

		var isStopped = dataCollector.stop();
		bundle.isStopped = isStopped;
		defered.resolve(bundle);

		return defered.promise;
	}

	/* 
	 * This function stops the dashboard-ops procedure and un-registers a listener.
	 * If there are zero remaining listeners than the DAQ loop actually stops running.
	 */
	this.stop = function(uid){
		var defered = q.defer();
		var removedListener = removeListener(uid);
		var numListeners = getNumListeners();
		var bundle = createStopBundle(uid);

		function onSuccess(rBundle) {
			defered.resolve(rBundle);
		}
		function onError(rBundle) {
			defered.resolve(rBundle);
		}

		if(removedListener && (numListeners === 0)) {
			// We need to stop the dashboard-service.
			innerStop(bundle)
			.then(onSuccess, onError);
		} else {
			// We don't need to stop the dashboard-service.  It should already
			// be stopped.
			onSuccess(bundle);
		}
		return defered.promise;
	};

	function createConfigIOBundle(channelName, attribute, value) {
		var bundle = {
			'channelName': channelName,
			'attribute': attribute,
			'value': value,

			'registersToWrite': [],
			'valuesToWrite': [],

			'isError': false,
			'errMessage': '',
		};
		return bundle;
	}

	
	function getChannelInfo(channelName) {
		var deviceTypeName = curatedDevice.savedAttributes.deviceTypeName;
		var channels = dashboard_channel_parser.channels[deviceTypeName];

		var chInfo = channels[channelName];

		var info = {
			'type': chInfo.type,
			'ioNum': chInfo.ioNum,
			'name': chInfo.name,
		};

		return info;
	}
	function performWrites(bundle) {
		var executeWrite = false;
		if(bundle.registersToWrite.length >= 0) {
			if(bundle.valuesToWrite.length >= 0) {
				executeWrite = true;
			}
		}
		var defered = q.defer();
		if(executeWrite) {
			// console.log('Executing iWriteMany', bundle.registersToWrite, bundle.valuesToWrite);
			curatedDevice.iWriteMany(bundle.registersToWrite, bundle.valuesToWrite)
			.then(function(res) {
				defered.resolve({
					'registers': bundle.registersToWrite,
					'values': bundle.valuesToWrite,
				});
			})
			.catch(function(err) {
				defered.resolve({
					'registers': bundle.registersToWrite,
					'values': bundle.valuesToWrite,
					'err': err,
				});
			});
		} else {
			defered.resolve({
				'registers': bundle.registersToWrite,
				'values': bundle.valuesToWrite,
			});
		}
		return defered.promise;
	}

	this.configIO = function(channelName, attribute, value) {
		// console.log('in this.configIO', channelName, attribute, value);
		var defered = q.defer();

		var bundle = createConfigIOBundle(channelName, attribute, value);

		var validAttributes = {
			'analogEnable': {
				'enable': 1,
				'disable': 0,
			},
			'digitalDirection': {
				'output': 1,
				'input': 0,
			},
			'digitalState': {
				'high': 1,
				'low': 0,
			},
		};

		var chInfo = getChannelInfo(channelName);
		var chType = chInfo.type;

		var chNum = 0;
		var chNumValid = false;
		try {
			if(typeof(value) === 'string') {
				chNum = validAttributes[attribute][value];
			} else if(typeof(value) === 'number') {
				chNum = value;
			}
			if(typeof(chNum) === 'number') {
				chNumValid = true;
			}
		} catch(err) {
			// catch the error...
		}

		
		var bitMask = 0x0FFFFFFF;
		if(chNumValid) {
			if(chType === 'AIN') {
				// We don't have to really write anything...
			} else if(chType === 'DIO') {
				if(attribute === 'digitalDirection') {
					bundle.registersToWrite.push('DIO_INHIBIT');
					bundle.valuesToWrite.push(bitMask ^ (1<<chInfo.ioNum));
					bundle.registersToWrite.push('DIO_DIRECTION');
					bundle.valuesToWrite.push(chNum<<chInfo.ioNum);
				} else if(attribute === 'digitalState') {
					bundle.registersToWrite.push('DIO_INHIBIT');
					bundle.valuesToWrite.push(bitMask ^ (1<<chInfo.ioNum));
					bundle.registersToWrite.push('DIO_STATE');
					bundle.valuesToWrite.push(chNum<<chInfo.ioNum);
				}
			} else if(chType === 'FLEX') {
				if(attribute === 'digitalDirection') {
					bundle.registersToWrite.push('DIO_INHIBIT');
					bundle.valuesToWrite.push(bitMask ^ (1<<chInfo.ioNum));
					bundle.registersToWrite.push('DIO_DIRECTION');
					bundle.valuesToWrite.push(chNum<<chInfo.ioNum);
				} else if(attribute === 'digitalState') {
					bundle.registersToWrite.push('DIO_INHIBIT');
					bundle.valuesToWrite.push(bitMask ^ (1<<chInfo.ioNum));
					bundle.registersToWrite.push('DIO_STATE');
					bundle.valuesToWrite.push(chNum<<chInfo.ioNum);
				} else if(attribute === 'analogEnable') {
					bundle.registersToWrite.push('DIO_INHIBIT');
					bundle.valuesToWrite.push(bitMask ^ (1<<chInfo.ioNum));
					bundle.registersToWrite.push('DIO_ANALOG_ENABLE');
					bundle.valuesToWrite.push(chNum<<chInfo.ioNum);
				}
			} else if(chType === 'AO') {
				if(attribute === 'analogValue') {
					bundle.registersToWrite.push(chInfo.name);
					bundle.valuesToWrite.push(value);
				}
			} else {
				// Don't do anything...
			}
		}

		// console.log('resolving..', chInfo, chType, chNum, chNumValid, bundle.registersToWrite, bundle.valuesToWrite);
		performWrites(bundle)
		.then(defered.resolve)
		.catch(defered.resolve);
		return defered.promise;
	};
}
551239
private function createController(): void
    {
        $aFields  = $this->getArguments();
        $aCreated = [];

        try {

            $aClasses = array_filter(explode(',', $aFields['CLASS_NAME']));

            foreach ($aClasses as $sClass) {

                $aFields['CLASS_NAME'] = $sClass;
                $this->oOutput->write('Creating controller <comment>' . $sClass . '</comment>... ');

                //  Check for existing controller
                $sPath = static::CONTROLLER_PATH . $sClass . '.php';
                if (file_exists($sPath)) {
                    throw new ControllerExistsException(
                        'Controller "' . $sClass . '" exists already at path "' . $sPath . '"'
                    );
                }

                $this->createFile($sPath, $this->getResource('template/controller.php', $aFields));
                $aCreated[] = $sPath;
                $this->oOutput->writeln('<info>done!</info>');
            }

        } catch (\Exception $e) {
            $this->oOutput->writeln('<error>failed!</error>');
            //  Clean up created models
            if (!empty($aCreated)) {
                $this->oOutput->writeln('<error>Cleaning up - removing newly created controllers</error>');
                foreach ($aCreated as $sPath) {
                    @unlink($sPath);
                }
            }
            throw $e;
        }
    }
1178770
private void ensure_dashboards() {
        HttpURLConnection urlConnection = null;
        OutputStreamWriter wr = null;
        URL myurl = null;

        try {
           myurl = new URL(url_str + "/dashboards.json");
           urlConnection = (HttpURLConnection) myurl.openConnection();
           urlConnection.setRequestMethod("GET");
           urlConnection.setDoInput(true);
           urlConnection.setDoOutput(true);
           urlConnection.setReadTimeout(coppereggApiTimeoutInMillis);
           urlConnection.setRequestProperty("content-type", "application/json; charset=utf-8");
           urlConnection.setRequestProperty("Authorization", "Basic " + basicAuthentication);

           int responseCode = urlConnection.getResponseCode();
           if (responseCode != 200) {
               logger.warn("Bad responsecode " + String.valueOf(responseCode)+ " from Dahsboards Index: " +  myurl);
           }
        } catch (Exception e) {
            exceptionCounter.incrementAndGet();
            logger.warn("Exception on dashboards index request "+ myurl + "  "+ e);
        } finally {
            if (urlConnection != null) {
                try {
                    InputStream in = urlConnection.getInputStream();
                    String theString = convertStreamToString(in);
                    for (Map.Entry<String, String> entry : dashMap.entrySet()) {
                        String checkName =  entry.getKey();
                        try {
                            String Rslt = groupFind(checkName, theString, 1);
                            if(Rslt != null){
                                // Update it
                                Rslt = Send_Commmand("/dashboards/" + Rslt + ".json", "PUT", entry.getValue(),1);
                            } else {
                                // create it
                                Rslt = Send_Commmand("/dashboards.json", "POST", entry.getValue(),1);
                            }
                        } catch (Exception e) {
                            exceptionCounter.incrementAndGet();
                            logger.warn("Exception in dashboard update or create: "+ myurl + "  "+ e);   
                        }
                    }
                } catch (IOException e) {
                    exceptionCounter.incrementAndGet();
                    logger.warn("Exception flushing http connection"+ e);
                }
            }
        }
    }
901531
public function postLaunchAction()
    {
        $reflected = new \ReflectionClass($this->_controllerInstance);
        if ($reflected->hasMethod('postLaunchAction')) {
            call_user_func(array(
                $this->_controllerInstance,
                'postLaunchAction'
            ), null);
        }
    }
382854
def create
      @dashboard = MnoEnterprise::Impac::Dashboard.new(dashboard_params)

      # Abort on failure
      unless @dashboard.save
        return render json: { errors: dashboard.errors }, status: :bad_request
      end

      MnoEnterprise::EventLogger.info('dashboard_create', current_user.id, 'Dashboard Creation', @dashboard)
      render :show
    end
248823
private static function checkController()
    {
        $bSetFallback = false;
        $sControllerNamespace = Configuration::read('application.namespace') . '\Controller\\' . self::getController();
        if (class_exists($sControllerNamespace) === false) {
            $bSetFallback = true;
        }
        if (method_exists($sControllerNamespace, self::getAction()) === false) {
            $bSetFallback = true;
        }
        if ($bSetFallback === true) {
            // Set controller
            $sFallbackController = RouteCollection::getFallbackController();
            self::setController($sFallbackController);
            // Set action to route action
            $sFallbackAction = RouteCollection::getFallbackAction();
            self::setAction($sFallbackAction);
            // Set action to route action
            $arsFallbackParameter = array('code' => 404);
            self::setParameter($arsFallbackParameter);
        }
    }
404599
function () {
    var changed = false;
    var controllerAxes = this.controller.axes;
    var i;
    var previousAxis = this.axis;
    var changedAxes = this.changedAxes;

    // Check if axis changed.
    this.changedAxes.length = 0;
    for (i = 0; i < controllerAxes.length; ++i) {
      changedAxes.push(previousAxis[i] !== controllerAxes[i]);
      if (changedAxes[i]) { changed = true; }
    }
    if (!changed) { return false; }

    this.axis.length = 0;
    for (i = 0; i < controllerAxes.length; i++) {
      this.axis.push(controllerAxes[i]);
    }
    this.el.emit(EVENTS.AXISMOVE, this.axisMoveEventDetail, false);
    return true;
  }
635457
function () {
    this.controller = controllerUtils.findMatchingControllerWebXR(
      this.system.controllers,
      this.data.hand
    );
    // Legacy handle to the controller for old components.
    this.el.components['tracked-controls'].controller = this.controller;

    if (this.data.autoHide) { this.el.object3D.visible = !!this.controller; }
  }
856367
public function runController($controller = null, $action = null, $values = array())
    {
        if($action != null && method_exists($controller, $action))
        {
            if($values != null)
            {
                call_user_func_array(array($controller, $action), $values);
            }
            else
            {
                $controller->{$action}();
            }
        }
        else
        {
            $controller;
        }
    }
308947
public function run() {
        $this->_hookManager->runBeforeSystem();

        $urlArray = explode('/', $this->_url);
        //Deletes last element if empty
        $lastElement = end($urlArray);
        if ($lastElement == '') {
            array_pop($urlArray);
        }
        reset($urlArray);

        // If present take the first element as the controller
        $tmpController = isset($urlArray[0]) ? array_shift($urlArray) : 'index';
        $action = null;

        //Prepare the GET params in order to pass them to the Controller
        $myGet = $_GET;
        if(isset($myGet['url'])){
            unset($myGet['url']);
        }

        if ($this->applyStaticRouting($tmpController)) {
            $this->_hookManager->runBefore(); // Runs before controller hooks
            include(ROOT . DS . $tmpController);
            $this->_hookManager->runAfter(); // Runs after controller hooks
        } elseif ($this->applyRouting($tmpController, $action, $urlArray)) {
            ($action === null) ? $action = 'index' : $action;
            $tmpController = '\\pff\\controllers\\'.$tmpController;
            $controller = new $tmpController($tmpController, $this, $action, array_merge($urlArray,$myGet));
        } elseif (file_exists(ROOT . DS . 'app' . DS . 'controllers' . DS . ucfirst($tmpController) . '_Controller.php')) {
            $action = isset($urlArray[0]) ? array_shift($urlArray) : 'index';
            $controllerClassName = '\\pff\\controllers\\'.ucfirst($tmpController) . '_Controller';
            $controller          = new $controllerClassName($tmpController, $this, $action, array_merge($urlArray,$myGet));
        } else {
            throw new RoutingException('Cannot find a valid controller.', 404);
        }

        if (isset($controller)) {
            $this->_action = $action;
            $this->_moduleManager->setController($controller); // We have a controller, let the modules know about it
            ob_start();
            $this->_hookManager->runBefore(); // Runs before controller hooks
            if ((int)method_exists($controller, $this->_action)) {
                call_user_func_array(array($controller, "beforeAction"), $urlArray);
                call_user_func(array($controller, "beforeFilter"));
                call_user_func_array(array($controller, $this->_action), $urlArray);
                call_user_func(array($controller, "afterFilter"));
                call_user_func_array(array($controller, "afterAction"), $urlArray);
                $this->_hookManager->runAfter(); // Runs after controller hooks
                ob_end_flush();
            } else {
                throw new RoutingException('Not a valid action: ' . $action, 404);
            }
        }
    }